错误登录后404.0。 Asp.Net MVC和IIS 7.5

编程入门 行业动态 更新时间:2024-10-27 10:27:00
本文介绍了错误登录后404.0。 Asp.Net MVC和IIS 7.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经运行在IIS 7.5中一个ASP.NET MVC应用程序。经过身份验证的启用形式

I have a ASP.NET MVC app running over IIS 7.5 . Forms Authenticated enabled

我可以访问登录页面。 (这意味着这条路线是确定的),但是当我登录的应用程序应该发个帖子的数据的http://本地主机/ tgpwebged /帐号/登录来验证用户的身份。

I can access the login page. (Which means that route is ok) but when I log in the app should send a post data to localhost/tgpwebged/Account/Login to authenticate the user.

问题是,我的应用程序在寻找/帐号/登录的http://本地主机/帐号/登录(这不是路径)

The problem is that my application is looking for /Account/Login in localhost/Account/Login (This is not the path).

我尝试没有成功改变这种行为。

I am trying without success change this behavior.

这是我的 route.config

routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }

的web.config

<authentication mode="Forms"> <forms loginUrl="Account/Login"/> </authentication>

查看

<form method="post" action="/Account/Login">

此外IIS设置为接受匿名登录用户才能够访问登录页面。

Also IIS is set to accept Anonymous login for users to be able to access the login page.

这是我收到错误消息:

TTP错误404.0 - 未找到您正在寻找已被删除的资源,更名或暂时不可用。

TTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

部分的详细信息:

请求的URL 的http://本地主机:8081 /帐号/登录(右路径:的http://本地主机:8081 / tgpwebged /账户/登录)物理路径S:\\项目\\帐户\\登录(应该是S:\\项目\\ tgpwebged \\帐户\\登录)登录方法匿名登录用户匿名

Requested URL localhost:8081/Account/Login (right path: localhost:8081/tgpwebged/Account/Login ) Physical Path S:\Projects\Account\Login (Should be S:\Projects\tgpwebged\Account\Login) Logon Method Anonymous Logon User Anonymous

推荐答案

在POST会错误的URL,因为这是你在视图中提到。见

The POST is going to wrong URL because that is what you have mentioned in the view. See

<form method="post" action="/Account/Login">

这会一直张贴到&LT;主机名称&gt; /帐号/登录

尽量给无论是相对路径(或使用RESOLVEURL方法代替绝对路径) - 例如,在ASPX视图中,可以使用

Try to give either relative path (or substitute absolute path using ResolveUrl method) - for example, in aspx view, you can use

<form method="post" action='<%= this.ResolveUrl("~/Account/Login") %>' >

在剃刀(CSHTML)视图中,可以尝试(未经测试)

In razor (cshtml) view, you can try (untested)

<form method="post" action='@Url.Content("~/Account/Login")' >

更多推荐

错误登录后404.0。 Asp.Net MVC和IIS 7.5

本文发布于:2023-11-12 04:50:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580553.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   Asp   Net   IIS   MVC

发布评论

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

>www.elefans.com

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