default document not displaying complete url

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>

在与默认文档位置文本文件名为web.Config(no .txt,.xml或任何其他扩展名)相同的文件夹中,具有以下确切内容:

<?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>

在登录页面的Page_Init中写下以下行。

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
链接地址: http://www.djcxy.com/p/68408.html

上一篇: 通过Open Graph API发布时,Facebook wallpost图像不会呈现

下一篇: 默认文档不显示完整的网址