简单的表单验证网站登录后不重定向

编程入门 行业动态 更新时间:2024-10-25 04:20:31
本文介绍了简单的表单验证网站登录后不重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有建立在一个简单的身份验证模式网站。它运行良好本地和本地IIS,但在测试服务器中键入正确的凭据,这毕竟不是重定向到默认页面。

I have a website built on a simple authentication model. It runs fine locally and on local IIS, but it is not redirecting to the default page after typing in the correct credentials, all this in the test server.

在code去如下:

的的Web.config 的

<compilation targetFramework="4.0" /> <httpRuntime maxRequestLength="50000" /> <customErrors mode="On" defaultRedirect="exc/exc.aspx?e=1"> <error statusCode="404" redirect="exc/404.aspx?e=404"/> </customErrors> <authentication mode="Forms"> <forms loginUrl="admin/login.aspx" defaultUrl="admin/main.aspx" /> </authentication> <authorization> <allow users="*" /> </authorization> </system.web> <location path="admin"> <system.web> <authorization> <deny users="?"/> </authorization> </system.web> </location> <location path="admin/css/cms.css"> <system.web> <authorization> <allow users="?"/> </authorization> </system.web> </location> <location path="admin/css/styles.css"> <system.web> <authorization> <allow users="?"/> </authorization> </system.web> </location> <location path="admin/images"> <system.web> <authorization> <allow users="?"/> </authorization> </system.web> </location> <location path="exc/exc.aspx"> <system.web> <authorization> <allow users="?"/> </authorization> </system.web> </location>

的的login.aspx 的

该表单action属性是空白的,AutoEventWireup是真实的。

The form action property is blank and AutoEventWireup is true.

的 login.aspx.cs 的

protected void btnAuth_Click1(object sender, EventArgs e) { //Some code not shown... //User Validation ValidateUserResponse response = new ValidateUserResponse(); response = service.ValidateUser(request); if (response.State == true) FormsAuthentication.RedirectFromLoginPage(request.Alias, False); }

的 SignOut 的

protected void Page_Load(object sender, EventArgs e) { FormsAuthentication.SignOut(); Response.Redirect(FormsAuthentication.LoginUrl); }

在测试服务器的URL看起来是这样的:

On the test server the URL looks something like this:

192.168.1.58/TestSite/admin/login.aspx

在VS2010运作良好,以及在一次发表了我的本地IIS,但不明白为什么在TESTSERVER公布时,不登录后重定向到默认页面。显示了的网站需要登录和一个403 Forbidden错误的。

On VS2010 works well as well on my local IIS once published, but don't understand why isn't redirecting to the default page after the login when published on the TestServer. Showing that the website requires to log in and a 403 forbidden error.

本地我与这两个网址的形式和作品进行了测试(虚拟文件夹名称不同):

Locally I have tested it with both URL forms and works (the virtual folder name is different):

192.168.1.58/TestSite1/admin/login.aspx localhost/TestSite1/admin/login.aspx

我AP preciate对此事的任何建议,使其工作。

I'd appreciate any suggestions on the matter to make it work.

感谢您。

---------- -----------更新

我解决了这个问题是这样的:

I solved the problem this way:

  • 右键单击包含Web应用程序的虚拟目录
  • 转到目录安全性标签
  • 单击上修改
  • 未选中集成Windows身份验证
  • 匿名访问必须检查以及
  • 本作在web.config中的WebForms身份验证设置开始有对Web应用程序的影响。

    This made the WebForms Authentication settings on Web.Config to start having effect on the WebApp.

    感谢您。

    推荐答案

    请确保窗体身份验证在IIS中启用了Web服务器上。

    Make sure forms authentication is enabled in IIS on the web server.

    更多推荐

    简单的表单验证网站登录后不重定向

    本文发布于:2023-11-01 23:04:21,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1550667.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:表单   不重   网站登录   简单

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!