Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

default document not displaying complete url

Tags:

url

iis

.net-3.5

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.

like image 332
Punit Avatar asked Jan 14 '13 10:01

Punit


2 Answers

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>
like image 138
Atilla Ozgur Avatar answered Nov 05 '22 14:11

Atilla Ozgur


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>
like image 24
Chawathe Vipul S Avatar answered Nov 05 '22 14:11

Chawathe Vipul S