Reputation: 1445
I having an issue with default document of iis setting. In my site (http://mysite) I have provided the default document as login page. When user type the url (http://mysite) it does redirect user to login page but doesn't display the complete url (http://mysite/login.aspx). Looks like default document does server.transfer rather than response.redirect. Because of that when user enter their credentials and then click sign in, it again redirects them to login and from there on it works fine. So user has to enter their credentials twice.
My app is developed on .NET 3.5.
Is there a way that I can achieve response.redirect.
Upvotes: 7
Views: 2051
Reputation: 1475
Write following lines in 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
Upvotes: 0
Reputation: 14721
Use an index.html as default document in your base directory. In this index.html use either meta refresh or javascript redirect to your login.aspx page. See following example meta refresh code.
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>
Upvotes: 3
Reputation: 1696
In the same folder as default document place text file named web.Config (no .txt, .xml or any other extension) with 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>
Upvotes: 2