Coding:
- if (Request.RawUrl.ToLower().EndsWith(".html"))
- {
- if (Request.Cookies[".ASPXAUTH"] != null)
- {
- string value = Request.Cookies[".ASPXAUTH"].Value;
- if (value == null || value == "")
- {
- Response.Redirect("~/Account/LogOn");
- }
- }
- else
- {
- Response.Redirect("~/Account/LogOn");
- }
- }
Here .ASPXAUTH is the Form Authentication Cookies and Account is the Controller and LogOn is the actionand also add below coding in webconfig section:
- <buildProviders>
- <add extension=".html" type="System.Web.Compilation.PageBuildProvider" />
- <add extension=".htm" type="System.Web.Compilation.PageBuildProvider" />
- </buildProviders>
-
- <handlers>
- <add name="HTML" path="*.html" verb="GET, HEAD, POST, DEBUG" type="System.Web.UI.PageHandlerFactory" resourceT
- ype="Unspecified" requireAccess="Script" />
- <add name="HTM" path="*.htm" verb="GET, HEAD, POST, DEBUG" type="System.Web.UI.PageHandlerFactory" resourceTyp
- e="Unspecified" requireAccess="Script" />
- </handlers>