MVC3 - 所有路由都在本地工作,但不能远程工作
我有一个新的 MVC3 项目,其中包含一个名为 PublicController.cs 的控制器,其中包含 4 个相同的方法来测试路由的工作原理。它们之间唯一的区别是它们的名称,并且它们每个都指向不同的视图...
public class PublicController : Controller
{
//
// GET: /Public/
public ActionResult Index()
{
return View();
}
//
// GET: /Public/App
public ActionResult App()
{
return View();
}
//
// GET: /Public/Press
public ActionResult Press()
{
return View();
}
//
// GET: /Public/Contact
public ActionResult Contact()
{
return View();
}
}
在开发服务器中运行时,我可以通过访问这些 URL 来访问所有这些...
http://localhost:53367/Public/
或其等效项
http://localhost:53367/Public/Index
,然后
http://localhost:53367/Public/App
http://localhost:53367/Public/Press
http://localhost:53367/Public/Contact
但是,一旦它部署到我的远程 ASP.NET 4.0 服务器上,唯一有效的两个是:
http://localhost:53367/Public
http://localhost:53367/Public/Index
...所有其他的都给我一个 404 资源无法找到错误。
我的 Web 服务器与 netcetera 共享托管,使用子域进行此部署(以前在虚拟目录中存在 MVC 问题,但在子域中运行完整的 MVC2 应用程序没有问题)。我通过使用“发布到文件系统”选项进行部署,然后复制文件以及复制整个源项目。两者给出相同的结果。
有什么想法吗?
谢谢,
史蒂文
I have a new MVC3 project with one Controller called PublicController.cs which contains 4 identical methods for testing out how routing works. The only difference between them is their name, and that they each point to a different view ...
public class PublicController : Controller
{
//
// GET: /Public/
public ActionResult Index()
{
return View();
}
//
// GET: /Public/App
public ActionResult App()
{
return View();
}
//
// GET: /Public/Press
public ActionResult Press()
{
return View();
}
//
// GET: /Public/Contact
public ActionResult Contact()
{
return View();
}
}
I can get to all of them when running in the development server by visiting these URLs...
http://localhost:53367/Public/
or its equivalent
http://localhost:53367/Public/Index
and then
http://localhost:53367/Public/App
http://localhost:53367/Public/Press
http://localhost:53367/Public/Contact
However, once it's deployed to my remote ASP.NET 4.0 server, the only two that work are:
http://localhost:53367/Public
http://localhost:53367/Public/Index
... all others give me a 404 Resource cannot be found error.
My web-server is shared hosting with netcetera, using a sub-domain for this deployment (previously had problems with MVC in virtual directories, but have full blown MVC2 apps running in sub-domains no problem). I've deployed by using the "Publish to file system" option, then copying over the files aswell as just copying the entire source project over. Both give identical results.
Any ideas why?
Thanks,
Steven
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否确保 MVC 3 Framework 已安装到 Web 服务器,并且您站点的应用程序池设置为 4.x ASP.net?
Did you make sure MVC 3 Framework is installed to the web server, and that your site's app pool is set to 4.x ASP.net?