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.

Sharepoint 2010 with Microsoft Distributed Cache (Velocity)

Microsoft Distributed Cache “Velocity”  provides a highly scalable in-memory application cache for all kinds of data. By using cache, your application performance can improve significantly by avoiding unnecessary calls to the data source. You know for sharepoint farms caching and session management is one of challenging issue. Sharepoint farms have many servers as application servers, web front end (WFE) servers etc. And using Network  load balancing (NLB) services for efficiency. By default your caches are server specfic and you can not  use cached data by other WFE  servers except which one of them has cached the data.

Velocity offers a custom state provider for your ASP.NET Web applications. This lets Web applications spread  objects across the cache cluster, providing scalability. Due to the nature of “Velocity,” objects that you put in  must be serializable.

Alternatively you can use SQL Server for SessionState but this solution has some disadvantages.For example performance and high availability are the key points.

  • InProc – Fastest, but the more session data, the more memory is consumed on the web server, and that can affect performance.
  • StateServer – When storing data of basic types (e.g. string, integer, etc), in one test environment it’s 15% slower than InProc. However, the cost of serialization/deserialization can affect performance if you’re storing lots of objects. You have to do performance testing for your own scenario.
  • SQLServer – When storing data of basic types (e.g. string, integer, etc), in one test environment it’s 25% slower than InProc. Same warning about serialization as in StateServer.

You can also use 3rd party distributed caches that Memcached , ScaleOut, NCache,SharedCache some options .

Some advantages of Velocity:

  • Scalebility: Velocity provides a cache cluster with multiple hosts and spread cache data between hosts.You can add more servers to the cache cluster.
  • High Availablity:The high availability feature in Microsoft project code named “Velocity” supports continuous availability of your cached data by storing copies of that data on separate cache hosts. When you have high availability enabled on a multi-server cluster, your application can still retrieve its cached data if a cache server fails
  • Cache Notifications:Microsoft project code named “Velocity” offers cache notifications that allow your applications to receive asynchronous notifications when a variety of cache operations occur on the cache cluster. Cache notifications also provide automatic invalidation of locally cached objects
  • Concurrency Models :To help your application deal with concurrency issues, “Velocity” supports optimistic and pessimistic concurrency models
  • SessionState Provider: you can share sessions across multiple sites. You can now host your application in multiple sites and have users visit one location to another without losing their sessions.

About Performance of Velocity :
MSDN Magazine Article about Velocity says “Simply put, if accessing the cache is not faster than accessing your database, there is no need to have it. Having said that, what should you expect in terms of performance from a good distributed cache?

The first thing to remember is that a distributed cache is usually OutProc or remote, so access time will never be as fast as that of a stand-alone InProc cache (for example, ASP.NET Cache). In an InProc stand-alone cache, you can probably read 150,000 to 200,000 items per second (1KB object size). With an OutProc or a remote cache, this number drops significantly. In terms of performance, you should expect about 20,000 to 30,000 reads per second (1KB object size) as the throughput of an individual cache server (from all clients hitting on it). You can achieve some of this InProc performance by using a client cache (in InProc mode), but that is only for read operations and not for write operations. You sacrifice some performance in order to gain scalability, but the slower performance is still much faster than database access.”
.
Using Velocity With Sharepoint:
I assume that you already setup and configure your distribute cache hosts and clusters up and running.

1)Copy Client DLL’s to your bin directory
  • CacheBaseLibrary.dll
  • ClientLibrary.dll
  • FabricCommon.dll
  • CASBase.dll
Important  : In my case first i try to register dll to GAC but it occurs some dependency problems you may use copy bin options.

2)Web.Config configurations:
into configSection tag:
< section name=”dataCacheClient” type=”Microsoft.Data.Caching.DataCacheClientSection, CacheBaseLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91″ allowLocation=”true” allowDefinition=”Everywhere” / >
into Configuration tag: (For example after < / configSections > tag)
< dataCacheClient deployment=”simple” >
< localCache isEnabled=”true” sync=”TTLBased” ttlValue=”300″  / >
<hosts>
<host name=”bugrapostaci” cacheHostName=”DistributedCacheService” cachePort=”22233″  / >
</hosts>
</dataCacheClient>

Into SafeControls tag:

<SafeControl Assembly=”CacheBaseLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91″ Namespace=”Microsoft.Data.Caching” TypeName=”*” Safe=”True” SafeAgainstScript=”False”  / >

<SafeControl Assembly=”ClientLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91″ Namespace=”Microsoft.Data.Caching” TypeName=”*” Safe=”True” SafeAgainstScript=”False”  / >

My Code for sample webpart:

using System;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using Microsoft.Data.Caching;

 

namespace DistributedCacheTest.DistributedCacheClient

{

public partial class DistributedCacheClientUserControl : UserControl

{

protected void Page_Load(object sender, EventArgs e)

{

DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[1];

 

////specify cache host(s)

servers[0] = new DataCacheServerEndpoint(“BUGRAPOSTACI”,

22233, “DistributedCacheService”);

 

//specify cache client configuration

DataCacheFactory mycacheFactory

= new DataCacheFactory(servers, true, false);

 

//get cache client for default cache

DataCache dCache = mycacheFactory.GetDefaultCache();

string cacheContent = dCache.Get(“TestKey”) as string;

Response.Write(“VALUE = “ + cacheContent);

}

}

}

 

Important :When installing Velocity If your religional settings is different from “en-xx” some language specific characters can be problematic .In my case because of turkish char “i” and “ı” i got exception “url not found” and unable to start cache cluster.  I solved this problem with change my religional settings of computer  to english and reinstalled velocity .

Important:Velocity client dll’s needs Custom Access Policy configuration when using bin directory copy-paste deployment. I suggest that you should change your “trust” option in your web.config to “Full” instead of using default value  of “WSS_Minimal”.
<trust level=”Full”  />

Download Microsoft Distributed Cache:
http://www.microsoft.com/downloads/en/details.aspx?FamilyId=B24C3708-EEFF-4055-A867-19B5851E7CD2&displaylang=en

Other Sources:

http://msdn.microsoft.com/en-us/magazine/dd861287.aspx
http://www.codeproject.com/KB/aspnet/p2pstateserver.aspx

End of article .)

.