我们如何在MVC应用程序中添加链接 [英] How we add a link in mvc application

查看:97
本文介绍了我们如何在MVC应用程序中添加链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生

我创建了一个mvc应用程序,并在名为contact.aspx的主文件夹中添加了一个页面. 并在共享页面的母版页中添加如下所示的内容

<%:Html.ActionLink(联系人",联系人",首页")%>

此链接显示在主页上,但是当我们单击此链接时,会出现类似这样的错误

找不到资源.
说明:HTTP404.您正在寻找的资源(或其依赖项之一)可能已被删除,名称更改或暂时不可用.请查看以下URL,并确保其拼写正确.

要求的网址:/Home/contact


请帮助我,我该如何解决此问题.

在此先感谢

Dear Sir

I create a mvc application and add a page in home folder named contact.aspx
and add a like in master page in folder shared as given below

<%: Html.ActionLink("contact", "contact", "Home")%>

this link is show in home page but when we click on this link it gives an error like this

The resource cannot be found.
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: /Home/contact


please help me, how can i remove this problem.

Thanks in advance

推荐答案

ActionLink方法采用参数"Text","Action","Controller"

根据传递给它的参数,它会在Home控制器上寻找一种名为 contact 的方法.如果此方法不存在,您将看到404错误.

确保该方法存在于控制器上.另外,检查外壳,您的控制器方法实际上应该是Contact ,并且应该相应地更改ActionLink.例如

The ActionLink method takes the arguments ''Text'', ''Action'', ''Controller''

Based on the parameters you have passed to it, it''s looking for a method called contact on your Home controller. If this method doesn''t exist, you''ll see the 404 error.

Make sure that the method exists on the controller. Also, check your casing, your controller method should really be Contact and you should change your ActionLink accordingly. e.g

Html.ActionLink("Contact", "Contact", "Home")


这篇关于我们如何在MVC应用程序中添加链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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