Posts

Detecting ASP.NET Session Timeouts

How Sessions Are Implemented http://aspalliance.com/520_Detecting_ASPNET_Session_Timeouts.all ASP.NET provides a framework for storing data that is specific to an individual user with the Session object. A page can add information to the Session object, and any other page can then retrieve the information for the same user. In order to preserve server memory, ASP.NET implements a rolling timeout mechanism which discards the session information for a user if no request is seen within the timeout period (default 20 minutes which is reset with each request). It is often useful in an ASP.NET site to know for a particular request if the user’s session information is still intact (that a timeout has not occurred). One common need is to be able to inform the user why they lost their session information, by redirecting to a page that describes the timeout amount and how to avoid the problem in the future. Without this technique it is difficult to know if a session variable is not present wheth...

Windows Communication Foundation

Image
(formerly known as Indigo, some people also called it "ServiceModel" because service comes under syste.ServiceModel) What is WCF? •Simply put, a better way for building distributed systems – it’s about messages – not platforms or runtimes •Simplifies development of connected applications through a new service-oriented programming model •Unification of Microsoft Distributed Computing Technologies •Interoperability with Applications Built on Other Technologies Why Need WCF •WCF provides the next generation of distributed communication on the basis of service oriented programming model. • Current distributed system –ASP.NET Web Services (ASMX) :Enables cross platform interoperability –The Microsoft Message Queue (MSMQ) : Enables transaction integration across multiple parties –.NET Remoting: communication with object across application domain boundaries •WCF is all about providing a single programming model that unifies the features of ASMX, MSMQ, Remoting ...

Setting the trust level for newly installed Web Parts

Problem description : Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=1 After installing a new SharePoint Web Part, it is not working and you get an error like Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed. Solutions: 1. Change the trust level for your SharePoint Web Part This means the trust level of your newly installed SharePoint Web Part is not set correctly. To fix this, follow these steps: Start the Visual Studio Command Prompt (in the program group Visual Studio Tools).Go to the directory where the dll is installed (typically c:\Inetpub\wwwroot\wss\VirtualDirectories\80\bin).Run the command gacutil /i newwebpartdll.dll. Run iisreset . Your newly installed SharePoint Web Part will be added to the global assembly cache (GAC) and everything shoul...

Unable to add selected web part(s).

Image
Every once in a while when you create a web part or upgrade web part, or do some of things developers do when developing web parts, there comes the chilling moment, when you see an error message such as the one below: So the question is what we do in this case? Before you hit the discussion boards, or worse, start pulling your hair, here are couple of tips you can use to troubleshoot the issue: 1. Make sure the control is registered as safe in the web.config (...actually the error says what it means, right) 2. Make sure the assembly is accessible and in the [port]bin folder. (obvious, but worth mentioning) 3. Make sure the assembly name in the *.webpart definition file, matches the assembly name in the safe control element in web.config 4. Make sure you don't have more than one *.webpart file for the same web part in the web part catalog. This may happen if you changed the name of the *.webpart file. 5. Restart IIS to start clean. Attach the debugger to the w3wp.exe process and try...

.NET Remoting look

Image
.NET Remoting uses a flexible and extremely extensible architecture. Remoting uses the .NET concept of an Application Domain (AppDomain) to determine its activity. An AppDomain is an abstract construct for ensuring isolation of data and code, but not having to rely on operating system specific concepts such as processes or threads. A process can contain multiple AppDomains but one AppDomain can only exist in exactly one process. If a call from program logic crosses an AppDomain boundary then .NET Remoting will come into place. An object is considered local if it resides in the same AppDomain as the caller. If the object is not in the same appdomain as the caller, then it is considered remote. In .NET remoting, the remote object is implemented in a class that derives from System.MarshalByRefObject . The MarshalByRefObject class provides the core foundation for enabling remote access of objects across application domains. A remote object is confined to the application domain where it is ...

Using ResolveUrl in an HTML Helper

Refer below URL for very nice and clean approach: http://stephenwalther.com/blog/archive/2009/02/18/asp.net-mvc-tip-47-ndash-using-resolveurl-in-an-html.aspx

How to resolve relative url's without ResolveUrl

Sometimes you need to resolve relative url's without ResolveUrl. If the code is executing outside a Control, for example in an IHttpHandler or business layer code somewhere that has no reference to a Control, you can't call Control.ResolveUrl. The System.Web.VirtualPathUtility class has some very useful method for converting from an app relative path to an absolute path: string absoluteUrl = VirtualPathUtility .ToAbsolute(relativeUrl);