Igor Kitsula - Developer

A Programmer Reference

 

Using SQL Server for ASP .NET session state on hosting service provider

Can be several reasons why to use SQL Server for session state. In my case hosting service provider does not allow me to control application pool so user losing his session state from time to time and it’s very big issue. There are a lot of articles in Internet how to setup database to store ASP.NET session state, but no one explains how to setup it on a remote SQL Server database where you have no ‘sa’ rights. The problem with a standard InstallSqlState.sql script is that it tries to create SQL server job for cleaning up database from expired sessions.

Read more...Read more...

MVC Custom Error Pages

In previous article I shown you how to use log4net to log errors and redirect to custom error page. The problem in this approach is redirection. It’s not good for SEO to make redirection to custom error page.

Read more...Read more...

How to Compress components with gzip OR Enable dynamic and static compression

According to the YSlow article compressing with gzip generally reduces the response size by about 70%.
As we can see little change in settings can improve performance of website.
As this is IIS web server setting you can configure it in two ways:

Read more...Read more...

MVC Custom Error Pages (Log to database with Log4Net and notify by email)

MVC Custom error pages (log to database with Log4Net and notify by email)
There is a lot articles in web how to create and use custom error pages. I tried to implement one more solution and give you my example how to handle and log errors on website using Log4Net library and notify about error by email.

Read more...Read more...

Configure Expired Headers on IIS7

YSlow: "Web pages are becoming increasingly complex with more scripts, style sheets, images, and Flash on them. A first-time visit to a page may require several HTTP requests to load all the components. By using Expires headers these components become cacheable, which avoids unnecessary HTTP requests on subsequent page views. Expires headers are most often associated with images, but they can and should be used on all page components including scripts, style sheets, and Flash." More…

Read more...Read more...

Configure entity tags (ETags) on IIS7

YSlow: "Entity tags (ETags) are a mechanism web servers and the browser use to determine whether a component in the browser's cache matches one on the origin server. Since ETags are typically constructed using attributes that make them unique to a specific server hosting a site, the tags will not match when a browser gets the original component from one server and later tries to validate that component on a different server." More…

Read more...Read more...

Custom Role Provider for MVC

In previous article I explain how to create Custom Membership Provider to authorize user and protect controls and pages. But what if you want to show or protect some area, controller or page for specific group of users? For example allow access to Admin Panel only for admins.

Read more...Read more...

Custom Membership Provider for MVC

.NET Framework allow you authorization engine based on two layer security: users and roles. Most popular is SQL Membership Provider and it contains methods and properties specific to using SQL as a data store for membership information. But for standard Membership provider you should create separate database. To use users or contacts information from your DB for authentication users with standard .NET form authorization you can create Custom Membership Provider and Custom Role Provider. Today we will create simple Custom Membership Provider and I’ll show how to configure it for using in MVC.

Read more...Read more...

Rewriter. Redirect to with or without www

One of the good rules of SEO is to keep domain name of website the same. This rule include prefix www. To implement this rule we can use simple rule for URL Rewriter:

<rewrite>
   <rules>
     <rule name="Redirect to kitsula.com without www." stopProcessing="true">
       <match url=".*" />
       <conditions>
         <add input="{HTTP_HOST}" pattern="^www.kitsula.com$" />
       </conditions>
       <action type="Redirect" url="http://kitsula.com/{R:0}" redirectType="Permanent" />
     </rule>
   </rules>
</rewrite>
Read more...Read more...