忽略默认文档的表单身份验证

Forms Authentication Ignoring Default Document(忽略默认文档的表单身份验证)
本文介绍了忽略默认文档的表单身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了一天半的时间试图解决这个问题.基本上有一个 ASP.net 网站,在 IIS7 上使用 Framework 4.0 进行表单身份验证.

I have spent a day and a half trying to resolve this issue. Bascially have an ASP.net website with Forms Authentication on IIS7 using Framework 4.0.

除了没有指定文档(应该解析为默认文档)的情况下,授权的东西似乎对每个场景都适用.

The Authorization stuff seems to be working perfectly for every scenario with the exception of hitting it with no document specifed (Should resolve to Default Doc).

例如(请不要在现场苛刻,它仍在开发中;)),http://www.rewardroster.com/Default.aspx 完美运行,此页面应允许匿名在 web.config 中指定的访问权限.

For example (Please don't be harsh on site its still be developed ;) ), http://www.rewardroster.com/Default.aspx works perfectly, this page should allow anon access as specified in the web.config.

但如果我直接点击 www.rewardroster.com,它会重定向到登录页面,返回 URL 设置为/"或 Login.aspx?ReturnUrl=%2f

but if I hit www.rewardroster.com Directly it redirects to the login page with Return URL set to "/" or Login.aspx?ReturnUrl=%2f

我尝试过的一些事情:

1) 将身份验证设置为无,然后默认文档工作,所以这不是问题.

1) Set Authentication to None and then the Default document worked so thats not the issue.

2) 在 Web.config 中添加 DefaultDocument 属性

2) Added DefaultDocument attribute to Web.config

3) 删除了 IIS 默认文档列表中除 Default.aspx 之外的所有条目

3) Deleted all entries for in Default Document list in IIS except for Default.aspx

4) 在 Config 中添加 MachineKey 条目

4) Added MachineKey entry in Config

5) 在 IIS 中从集成管道切换到经典管道

5) Toggled from Integrated to Classic pipeline in IIS

这是我的配置中的内容:

Here is what's in my config:

  <authentication mode="Forms">
    <forms name="appNameAuth" loginUrl="Login.aspx" protection="All" timeout="60" slidingExpiration="true" defaultUrl="Default.aspx" path="/">
    </forms>
  </authentication>
  </authentication>

 <location path="Default.aspx">

非常感谢您抽出宝贵时间,希望有人知道这里发生了什么.

Thanks so much for your time and hope someone knows what is going on here.

推荐答案

这是我的解决方案:

Global.asax中,方法:Application_BeginRequest,放置如下:

In Global.asax, method: Application_BeginRequest, place the following:

if (Request.AppRelativeCurrentExecutionFilePath == "~/")  
   HttpContext.Current.RewritePath("HomePage.aspx");

很好,很简单,如果您的网站基于配置变量使用多个主页,您就有机会围绕要使用的主页构建逻辑.

Nice and simple, and you have a chance to build logic around what home page you want to use if your website uses multiple home pages based on configuration variables.

Dmitry.Alk

这篇关于忽略默认文档的表单身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)
Bind multiple parameters from route and body to a model in ASP.NET Core(在ASP.NET Core中将路由和主体中的多个参数绑定到一个模型)
Custom model binding in AspNet Core WebApi?(AspNet Core WebApi中的自定义模型绑定?)
How to minify in .net core mvc view?(如何在.Net核心MVC视图中缩小?)