Thursday, May 29, 2014

How to remove ASP.NET response headers Server, X-AspNet-Version, X-AspNetMvc-Version and X-Powered-By?

Need two steps:
Step 1: add following code into Global.asax
protected void Application_PreSendRequestHeaders(object sender, EventArgs e)


Step 2
Add following config into web.config file


Is ASP.Net vNext The New Node.js

Monday, May 26, 2014

How to valid URL in ASP.NET MVC data annotation?

[RegularExpression(@"^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$", ErrorMessage = "Invalid URL")]
public string Url { get; set; }

Website to test regular expression

Common Regular Expressions

Wednesday, May 21, 2014

How to fix problem, MSDTC on server xxx is unavailable?

Following are the steps I did to fix the problem:
- Uninstall: msdtc -uninstall
- Install: msdtc -install
- restarting DTC service;

- Restart SQL Server service

Tuesday, May 20, 2014

Wednesday, May 7, 2014

Why need method/function overloading in C#?

Keep same naming convention. Can not find any other benefit for overloading.

Optional parameter should be the first choice to try.
Do not put different purposes thing under same name.

Friday, May 2, 2014

How to add number only validation in ASP.NET MVC data model by Data Annotation attribute?

[Range(0, int.MaxValue, ErrorMessage = "Number please")]

How to solve, 401 unauthorized issue for ASP.NET Windows authentication in Visual studio 2013

Go to folder:

Open config file and Set windowsAuthentication to true
<windowsAuthentication enabled="true">