Thursday, March 28, 2013

Wednesday, March 27, 2013

How to deal with error "System.Data.MetadataException: Unable to load the specified metadata resource" when move edmx entity file to another project?

Cause: the res:// path changed. Need to be modified

Change connection for edmx file from
metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;
To
metadata=res://projectname/foldername.csdl|res://*/Model1.ssdl|res://*/Model1.msl;

Monday, March 25, 2013

What is constructor instruction in C#?

The red color part is intructing to call another contructor.
    class ListNode
    {
        private object data;
        private ListNode next;
        public ListNode(object dataValue) : this(dataValue, null)
        {
        }
        public ListNode(object dataValue, ListNode nextNode)
        {
            data = dataValue;
            next = nextNode;
        }
}

Friday, March 22, 2013

What is exception code: 0xe053534f

Mean: soft stack overflow
If hapends in IIS server, check code related to the permision

Wednesday, March 20, 2013

Hacking the HTML a tag in 100 characters

http://bilaw.al/2013/03/17/hacking-the-a-tag-in-100-characters.html
// Uncompressed
var links = document.links;
for(i in links) {
    links[i].onclick = function(){
        this.href = 'http://bit.ly/141nisR';
    };
}

// Compressed (was 100; now 67 characters exc. the link)
// Thanks to sgoel from HN
o=document.links;for(i in o){o[i].onclick=function(){this.href='//bit.ly/141nisR'}}

Monday, March 18, 2013

Why session expired so fast in ASP.NET?

A lot of reasons, check following list for detail:

http://blogs.msdn.com/b/johan/archive/2007/05/16/common-reasons-why-your-application-pool-may-unexpectedly-recycle.aspx

Thursday, March 14, 2013

Tuesday, March 12, 2013

How to read cookie value in ASP.NET MVC razor view?

@Request.Cookies["cookiename"].Value

@Response.Cookies["cookiename"].Value

Monday, March 11, 2013

ASP.NET Web API REST Security Basic

http://www.jamiekurtz.com/2013/01/14/asp-net-web-api-security-basics/

Thursday, March 7, 2013

How to keep ASP.NET application "alive" ?

There is one event call, Application_End in Global.asax. It happens when IIS application pool is recycled or the application itself is unloaded.
So add one call to self website to make application running again.

        protected void Application_End(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(1000);
            try
            {
                WebClient http = new WebClient();
                string Result = http.DownloadString(yourwebsiteurl);
            }
            catch (Exception ex)
            {
                string Message = ex.Message;
            }
        }

Tuesday, March 5, 2013

How to get started on “Service Unavailable 503” error in ASP.NET?

In IIS Server application pool default settings,
If application crashed 5 times in 5 minutes, IIS will return 503 error.
Check log to get detail of errors


   
     
   
   
     
   

Friday, March 1, 2013

How to reset Orchard admin password from database?

  update [Orchard_Users_UserPartRecord] 
  SET [Password] ='password', [PasswordFormat] ='Clear'
  where [UserName] ='admin'