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

asp.net-core – ASP.NET核心视图组件位置是否有ReSharper属性?

发布时间:2020-12-16 09:32:57 所属栏目:asp.Net 来源:网络整理
导读:我使用 Feature Slices in ASP.NET Core并希望将View Components放在与我的视图相同的文件夹中. 对于ReSharper,您可以为视图位置设置这样的属性: [assembly: AspMvcViewLocationFormat(@"~Features{1}{0}.cshtml")][assembly: AspMvcViewLocationFormat(
我使用 Feature Slices in ASP.NET Core并希望将View Components放在与我的视图相同的文件夹中.

对于ReSharper,您可以为视图位置设置这样的属性:

[assembly: AspMvcViewLocationFormat(@"~Features{1}{0}.cshtml")]
[assembly: AspMvcViewLocationFormat(@"~FeaturesShared{0}.cshtml")]

这使得ReSharper正确推断出视图的位置,用于视图生成和导航.但是,这不适用于View Components.

有没有办法为View Components获得相同的效果?

解决方法

你是如此接近,你只需要配置你的局部视图位置:

[assembly: AspMvcPartialViewLocationFormat(@"Features{1}{0}.cshtml")]

请注意,如果您开始使用区域,还有其他属性,并且还要注意我没有测试过这些:

[assembly: AspMvcAreaMasterLocationFormat("/Areas/{2}/Features/{1}/Views/{0}.cshtml")] 
[assembly: AspMvcAreaViewLocationFormat("/Areas/Features/Shared/Views/{0}.cshtml")]
[assembly: AspMvcAreaPartialViewLocationFormat("/Areas/Features/Shared/Views/{0}.cshtml")]

(编辑:李大同)

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

    推荐文章
      热点阅读