Mos*_*ose 14 iis-6 visual-studio-2010 visual-studio asp.net-mvc-2
我遇到了从VS.Net 2008/MVC 1迁移到VS.NET 2010(+ C#4.0)/ MVC 2的问题
在web.config中已经更新,该网站是在卡西尼运行良好,但现在我的问题是在IIS 6部署.
我更新了网站以使用ASP.Net 4运行,但无论我尝试什么URL,我总是有404错误.就好像路由没有被考虑在内一样(是的,通配符映射已经完成).
我不明白这个烂摊子,不能谷歌任何有趣的...谢谢你的建议!
Mos*_*ose 15
好的,我得到了答案(感谢同事)
从ASP.Net 2.0迁移到ASP.Net4.0时,如果遇到同样的问题,请检查Web服务扩展是否允许 ASP.Net v4 .
就我而言,在安装.Net框架4之后,它被禁止了.
Will&Mark:感谢您的帮助,希望它能帮助他人.
我想我知道发生了什么:在IIS6上,以及通配符映射,你需要一个默认文件(Default.aspx)来将文件夹请求路由到MVC处理程序.
Default.aspx
:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="YourNameSpace._Default" %>
<%-- Please do not delete this file. It is used to ensure that ASP.NET MVC is activated by IIS when a user makes a "/" request to the server. --%>
Run Code Online (Sandbox Code Playgroud)
并且Default.aspx.cs
:
using System.Web;
using System.Web.Mvc;
using System.Web.UI;
namespace YourNameSpace
{
public partial class _Default : Page
{
public void Page_Load(object sender, System.EventArgs e)
{
// Change the current path so that the Routing handler can correctly interpret
// the request, then restore the original path so that the OutputCache module
// can correctly process the response (if caching is enabled).
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
}
}
}
Run Code Online (Sandbox Code Playgroud)
当你说"就好像路由没有被考虑在内"时,我怀疑它实际上并非如此,这就是你的问题.
归档时间: |
|
查看次数: |
10445 次 |
最近记录: |