窗体身份验证和URL重写 [英] Form Authentication and URL Rewriting
问题描述
我想申请的的自定义窗体身份验证 ,以我的网站,我已经应用URL重写。
在的Global.asax
文件使用的Application_Start
这code。
I'm trying to apply Custom Forms Authentication to my website to which I already applied Url Rewriting.
using this code in Application_Start
in global.asax
file.
routes.MapPageRoute("bill-details", //Route Name
"{billno}", //URL with Parameters
"~/CallCenter/BillDetails.aspx" //Webforms page to Handle it.
);
但是,当我试图重写Loginpage网址,我不能够重写它。
But when I'm trying rewrite the Loginpage Url, I'm not able to rewrite it.
<forms loginUrl="/Login.aspx" name="MyCustomAuthentication" timeout="30"/>
的实际问题是,当我打开它会检查认证,如果没有通过身份验证,然后将其重定向到login.aspx的页面。一个页面
The Actual Problem is, when I open a page it checks for Authentication and if it is not Authenticated, then it redirects to Login.aspx page.
它显示为 mywebsite.com/Login.aspx?ReturnUrl =...
我没能改写这个。如果我不能删除返回URL然后我可以把登录
而不是的Login.aspx
的??
it shows as mywebsite.com/Login.aspx?ReturnUrl="..."
I'm not able to rewrite this. If I cannot Remove the Return URL then Can I place Login
Instead of Login.aspx
??
和如果我用这个code从这个职位 - > <一个href=\"http://stackoverflow.com/questions/3716153/how-to-remove-returnurl-from-url/9796693#9796693\">How从URL中移除RETURNURL?
and If I use this Code from this post -> How to remove returnurl from url?
如果我用这个,那么控制循环一遍又一遍,它说 - 过多的重定向。我认为这个问题是,当控制转到登录
网页像 mywebsite.com/Login
,然后检查验证并重定向到的Login.aspx
页。和你的code再次重定向到登录页面。这个循环仍在继续。
If I use this, then the control loops over and over and it says - Too many Redirects. I think the problem is, when the Control goes to Login
Page like mywebsite.com/Login
, then It checks for authentication and It redirects to Login.aspx
page. and your code redirects again to Login page . This loop continues.
我也不需要返回URL,因为我的用户可以登录第一中序来访问我的网站。
I also do not require the Return Url because I Users have to login first Inorder to access my website.
所以,你能不能帮我在卸下返回URL也?以及在URL重写??
So Can you help me in Removing the Return Url also?? And also in URL Rewriting ??
我不能够解决这个问题!
I'm not able to solve this!!
检查我的网站。 - > http://orders.maabookings.com
用户ID - 临时密码 - 温度
Check my website. -> http://orders.maabookings.com
UserId - temp Password - temp
在此在登录页面,其显示为 http://orders.maabookings.com/Login.aspx?ReturnUrl=%2f
我需要这是 http://orders.maabookings.com/Login
我该怎么做?
In this In the Login page, Its displaying as
http://orders.maabookings.com/Login.aspx?ReturnUrl=%2f
I need this to be http://orders.maabookings.com/Login
How can I do this??
推荐答案
添加一个web.config到你的Login.aspx放在这个文件夹
add a web.config to the folder where your Login.aspx placed
<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
<location path="Login.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
</configuration>
和在Global.asax中
and in Global.asax
Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
' Fires upon attempting to authenticate the use
Dim _URL As String = Request.Url.ToString
If _URL.Contains("ReturnUrl") Then
Response.Redirect("/Login")
End If
End Sub
我认为这可以帮助你。
I think this helps you.
这篇关于窗体身份验证和URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!