MVC 4中的页面导航 [英] page navigation in MVC 4

查看:60
本文介绍了MVC 4中的页面导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我是MVC 4的新手.

我不知道如何从"Global.asax"页面重定向到"index.cshtml".

我需要你的帮助.

预先感谢.

Hi All,

I am new to MVC 4.

I don''t know how to redirect to "index.cshtml" from "Global.asax" Page.

i need your help.

Thanks in advance.

推荐答案

Response.Redirect("~/<controllername>");</controllername>




or

Response.Redirect("~/<controllername>/Index");</controllername>



"controllername"是index.cshtml文件的文件夹名称.



但是,如果您不了解这些内容,我可以建议您在www.asp.net上学习教程.



''controllername'' being the foldername of your index.cshtml file.



But if you don''t know this stuff I can seriusly suggest taking a tutorial on www.asp.net


首先,Global.asax不是一页.它是ASP.net和某些WCF方案中应用程序级事件的全局处理程序.
重定向有多种方法:

http://msdn.microsoft. com/en-us/library/system.web.mvc.controller.redirecttoaction%28v = vs.100%29.aspx [ http://msdn.microsoft.com/en-us/library/ms524309%28v = vs.90%29.aspx [ ^ ]

但是,您不会直接重定向到MVC中的视图.没有看到更多代码,这很困难,但是我总是发现使用RedirectToAction与MVC相适应.
To start off with, Global.asax isn''t a page. It''s a global handler for application level events in ASP.net and certain WCF scenarios.

There are a number of ways to redirect:

http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.redirecttoaction%28v=vs.100%29.aspx[^]

http://msdn.microsoft.com/en-us/library/ms524309%28v=vs.90%29.aspx[^]

You wouldn''t redirect directly to a view in MVC though. Without seeing more of your code it''s difficult, but I''ve always found using RedirectToAction fits the bill with MVC.


这篇关于MVC 4中的页面导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆