gpt4 book ai didi

asp.net - 如何在 Asp.Net 和 Asp.Net Core 中动态路由静态文件

转载 作者:行者123 更新时间:2023-12-05 08:08:59 25 4
gpt4 key购买 nike

如何在 Asp.Net 和 Asp.Net Core 中动态路由静态文件

大家好,我必须构建一个应用程序,它将同时显示静态文件和动态内容,我如何使用 Asp.Net Core 和 Asp.Net MVC 做到这一点

例子

       I have site 

http://dummy.com/

现在有一些路由我需要服务器其默认内容,但根据请求是来自移动设备还是桌面,我需要更改文件

          Ex : http://dummy.com/category1
index.html
index-m.html

in this category1 has a folder & in the site and it has two static files like above
now when there is a request for "http://dummy.com/category1" i have to check wether its from mobile or desktop
if its mobile "index-m.html" should be server else "index.html" should be served

Ex : http://dummy.com/category/getcategories

this is a dynamic route , when this is requested it should go to its default Action method and get the result

任何人都可以帮助我,我必须在这里做什么才能得到这个

最佳答案

要提供静态文件,在 RegisterRoutes(RouteCollection routes) 中,添加以下忽略规则:

routes.IgnoreRoute("{file}.html");

有关其他信息,请参阅以下答案: Using ASP.NET routing to serve static files

关于asp.net - 如何在 Asp.Net 和 Asp.Net Core 中动态路由静态文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44154858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com