加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 是否可以在ASP .NET MVC中使用没有控制器功能名

发布时间:2020-12-16 07:07:52 所属栏目:asp.Net 来源:网络整理
导读:VS为HomeController生成的默认代码是: HandleError() Public Class HomeController Inherits System.Web.Mvc.Controller Function Index() As ActionResult ViewData("Message") = "Welcome to ASP.NET MVC!" Return View() End Function Function About()
VS为HomeController生成的默认代码是:

<HandleError()> 
Public Class HomeController Inherits System.Web.Mvc.Controller

    Function Index() As ActionResult
        ViewData("Message") = "Welcome to ASP.NET MVC!"

        Return View()
    End Function

    Function About() As ActionResult
        Return View()
    End Function
End Class

假设我想为about页面创建一个不同的URL而不更改方法名称.我试过了:

'
' GET: /Home/Aboutblah

但这不起作用.当我去http://localhost:1957/Aboutblah时,我从ASP .NET服务器获得了404.

因此,我想知道“GET”文本块实际上是否做了什么以及是否可以在没有潜入ASAX文件的情况下摆弄URL.

解决方法

此外,您可以使用属性修饰方法:

[ActionName("Aboutblah")]

詹姆士

编辑我刚刚注意到你正在使用VB.你必须翻译成VB,也许:

<ActionName("Aboutblah")>

还有,是的,评论,即:

' Get /Home/Index

只是 – 评论.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读