我想为Azure Blob存储设置代理页面。
我希望所有匹配的请求/^MyArea\/Asset\/.*$/
都路由到MyArea.IndexController.AssetAction。
public class MyAreaAreaRegistration : AreaRegistration
{
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"MyArea_assets",
"MyArea/Asset/{resource}",
new { controller = "Index", action = "Asset"}
);
}
}
然后,我将在“操作”中执行以下操作。
public ActionResult Asset(string resource)
{
// fetch content from Azure Blob Storage and return it.
return Content(/* some conent */);
}
如果请求是正确的,/MyArea/Asset/foo
但如果请求无效,则可以/MyArea/Asset/foo.txt
。
如何让路由器忽略文件扩展名,并将所有内容传递给单个操作?
--
扩展名可以是任何.txt,.js,.json等。我仍然希望JsonResult重载能够在应用程序的其他地方工作。
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句