Unrecognized attribute “targetFramework” when deploying asp.net 4.0

Ok you start developement with .net framework 4.0 and possibly try to deploy your site to iis first time and getting this error :Unrecognized attribute “targetFramework” when deploying asp.net 4.0 Because you did not configure your iis run with .net framework 4.0.

For do it you have to change your path to

C:\Windows\Microsoft.NET\Framework64\v4.0.30319

that execute command of

aspnet_regiis.exe -iru

if you already do this and getting this error you should better to check your site application pool for correct .NET framework version chosen.

Application Pools->Select yours -> Basic Settings -> And change .NET framework version

Thats it folks.

 

Detect asyncronous postback in asp.net

You can detect asyncronous postback with ScriptManager.IsInAsyncPostBack property.

protected void Page_Load(object sender, EventArgs e) {       if (ScriptManager.GetCurrent(Page).IsInAsyncPostBack)       {            //Do your job here.       } } Happy Tips..

How to set host header II7 for SSL binding 443

Open the command prompt by clicking the start menu and typing “cmd” and hitting enter.

Navigate to C:\Windows\System32\Inetsrv\ by typing “cd C:\Windows\System32\Inetsrv\” on the command line.

Here is the syntax:

appcmd set site /site.name:”<YourIISSiteName>” /+bindings.[protocol=’https’,bindingInformation=’*:443:<YourhostHeaderValue>‘]

An Example:

appcmd set site /site.name:”DemoPortal” /+bindings.[protocol=’https’,bindingInformation=’*:443:demo.portalcompany.com‘]

 

c# getting day name for specific culture

Here is a small example for getting day name of a date by specific culture:

 

DateTime startDate = DateTime.Now;

DateTime endDate = DateTime.Now.AddDays(2);

 

CultureInfo c = new CultureInfo("tr-TR");

string startDayName = c.DateTimeFormat.DayNames[(int)startDate.DayOfWeek];

string endDayName = c.DateTimeFormat.DayNames[(int)endDate.DayOfWeek];

 

 

Happy Tips.

The given expression is never of the provided warning.

When you try to getting type of Generic variable “T” you get this warning.Here is the sample :

class CauseWarning {     public void make<T>(T value)     {     if (typeof(T) is Test)         Console.Write("Something");     } } public class Test { }

Here is the solution:


class CauseWarning {     public void make<T>(T value)     {     if (typeof(T).IsAssignableFrom(typeof( Test)))         Console.Write("Something");     } } public class Test { }

Type.IsAssignableFrom Method Determines whether an instance of the current Type can be assigned from an instance of the specified Type.true if the c parameter and the current Type represent the same type, or if the current Type is in the inheritance hierarchy of c, or if the current Type is an interface that c supports. false if none of these conditions are the case, or if c is a null reference.