Default document not displaying full URL

I have a problem with a standard iis installation document. On my site (http: // mysite) I provided the default document as the login page. When a user enters a URL (http: // mysite), he redirects the user to the login page, but does not display the full URL (http: //mysite/login.aspx). It appears that, by default, the document executes server.transfer, not response.redirect. Because of this, when the user enters his credentials, and then click "Login," he redirects them again to enter the system and from there it works fine. Therefore, the user must enter their credentials twice.

My application is developed on .NET 3.5.

Is there any way I can achieve response.redirect.

+7
source share
3 answers

Use index.html as the default document in your base directory. In this index.html, use either meta refresh or javascript redirect to login.aspx page. See the following meta-update code for an example.

your project

website index.html secure/login.aspx 

index.html

 <!DOCTYPE html> <html> <head> <title>YOUR PROJECT NAME</title> <meta http-equiv="refresh" content="0;URL='http://www.YOURDOMAIN:COM/secure/login.aspx'" /> </head> <body> <p> Click to <a href="http://www.YOURDOMAIN:COM/secure/login.aspx">Login</a> </p> </body> </html> 
+3
source

In the same folder where the default text file is located with the name web.Config (no .txt, .xml or any other extension) with the following exact content:

 <?xml version="1.0"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Redirect to login" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{URL}" pattern="^/$" /> </conditions> <action type="Redirect" url="/login.aspx" redirectType="Permanent" /> </rule> </rules> </rewrite> </system.webServer> </configuration> 
+1
source

Enter the following lines in the Page_Init of your login page.

 Protected Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init If Not MyBase.IsPostBack Then If HttpContext.Current.Request.Url.ToString.Contains("Login") = False Then Response.Redirect("~/Login.aspx") End If End Sub 
0
source

All Articles