如何解决从URL .Net MVC隐藏操作名称
我尝试了许多解决方案,以保留没有动作名称但没有成功的URL。 例: 代替 http:// localhost:51632 / Blog / Details / my-new-blog
TO
http:// localhost:51632 / Blog / my-new-blog
URL上面的Blog =控制器,my-new-blog = slug
我尝试了以下解决方案,但这只会更改url中的url,但不会加载页面 遵循我使用的RouteConfig
import time
import os
def find_txt_location(txt_filename):
if os.path.exists(txt_filename):
f = open(txt_filename)
lastCheckDate = f.read()
else:
path = os.getcwd()
lastCheckDate = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
full_path = path + '\\' + txt_filename
file = open(full_path,'w')
file.write(lastCheckDate)
file.close
return lastCheckDate
def updated_localtime(txt_filename):
lastCheckDate_new = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
content = open(txt_filename,'w')
content.write(lastCheckDate_new)
content.close()
find_txt_location('LastCheckTime.txt')
updated_localtime('LastCheckTime.txt')
AllBlog是列出所有博客的地方,每个博客旁边都有一个DETAILS按钮,但是当我单击DETAILS按钮时,该页面无法打开页面,它只会将url中的url更改为所需的url
下面是我的控制器动作
routes.MapRoute(
name: "BlogRoute",url: "{controller}/{slug}",defaults: new { controller = "Blog",action = "AllBlog",slug =UrlParameter.Optional}
);
在解决此问题方面非常感谢帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。