如何在mvc4 c中的clik链接后将页面重定向到另一个页面# [英] how to redirect page to another page after clik link in mvc4 c#

查看:52
本文介绍了如何在mvc4 c中的clik链接后将页面重定向到另一个页面#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请点击mvc4中的链接后告诉您如何将一个页面重定向到另一个页面。单击链接后错误是





描述:HTTP 404.您正在寻找的资源(或其中一个依赖项)可以已删除,更改名称或暂时不可用。请查看以下网址,确保拼写正确。



请求的URL:/Views/Home/Index.cshtml

Pls some one tell that how to redirect one page to another page after clicking link in mvc4. After clicking the link the error is


Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Views/Home/Index.cshtml

推荐答案

你提到的网址是错误的。

默认情况下,MVC中的路由配置接受网址,例如

{controller} / {Action} / {id,参数if if}

所以views / Home / Index.cshtml是文件夹级搜索,这里不需要。

您应该访问该页面: -

主页/仅限索引。

这将重定向到新页面,考虑Home是控制器,索引操作,Action方法有一个如下定义的视图



The Url which you have mentioned is wrong.
By default the route config in MVC accepts url like
{controller}/{Action}/{id,parameters if any}
So the views/Home/Index.cshtml is the folder level search which is not required here.
You should access the page with:-
Home/Index only.
This will redirect to a new page, considering Home is the controller, Index an action and the Action method has a view defined like below

public ActionResult Index()
{
    return View();
}







<html>
    <head>
         <title>XYZ</title>
    </head>
    <body>
        //anything here....
    </body>
</html>





然后从布局访问:



then access from layout with:

@Html.ActionLink("Click(ActionName goes here)","Index(Action method name)","Home(Controller name)")





谢谢

:)



Thanks
:)


这篇关于如何在mvc4 c中的clik链接后将页面重定向到另一个页面#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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