繁体   English   中英

更改URL asp.net

[英]Change URL asp.net

我正在使用C#在Visual Studio中构建一个项目。 当我尝试运行该程序时,出现错误Http404。我的问题是如何更改我的URL。

http://localhost:55188/login.aspx?ReturnUrl=%2f 

http://localhost:55188/Index.aspx.

页面login.aspx不再存在。

这是我的web.config

<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Forms">

  <forms defaultUrl="addRole.aspx" path="/"/>
</authentication>
<authorization>
  <deny users="?"/>
</authorization>
</system.web>  
<location path="LoggedIn.aspx">
<system.web>
  <authorization>
    <allow users="*"/>
  </authorization>
</system.web>
</location>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
</configuration>

谢谢。

您尝试访问的页面需要验证,并且您的web.config表示login.aspx可以提供该验证。 更改您的web.config,就可以了。

这是没有身份验证要求的web.config:

<configuration> <system.web> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> </system.web>
<appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" /> </appSettings> </configuration>

在Matthias Aslund正确启动后,您已指定要对用户进行身份验证,但未指定希望用户重定向到的“登录”页面,以便使用Web上form元素上的“ LoginUrl”属性进行登录。配置文件。 因此,如在此MSDN页面上LoginUrl属性上所指定的,将使用默认值“ Login.aspx”。 “ DefaultUrl”属性的用途不同如果未使用上面URL中可见的“ ReturnUrl”查询字符串值指定用户登录,则该属性将用作默认页面,以在登录后将用户重定向到该页面 -请参见DefaultUrl上的MSDN页面属性

如果您的应用程序中不再具有任何身份验证,也就是说, 任何用户都可以在没有用户名和密码的情况下访问您的应用程序,那么您需要按以下方式更改Web.config。 非常重要的一点是,您必须清楚,能够访问您的应用程序的任何用户现在都可以访问应用程序的任何部分,并且基于对用户进行身份验证/对应用程序已知的事实,将没有任何限制。 ,是特定用户,还是特定角色。

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="None" />
  </system.web>  
  <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
  </appSettings>
</configuration>

这将替换上面提供的Web.config文件的全部内容,但是必须清楚,这将从应用程序中删除所有身份验证(这似乎是您想要的)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM