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.
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>
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With