Возможно ли обрабатывать .html файлы, такие как .cshtml-файлы в asp.net бритве?Обработать .html в ASP.NET razor как .cshtml
Я хочу использовать Webstorm и VS рядом. (Webstorm для html и js stuff и VS для C# stuff)
Возможно ли обрабатывать .html файлы, такие как .cshtml-файлы в asp.net бритве?Обработать .html в ASP.NET razor как .cshtml
Я хочу использовать Webstorm и VS рядом. (Webstorm для html и js stuff и VS для C# stuff)
По умолчанию движок Razor ищет только .cshtml
и .vbhtml
файлов. Вы можете изменить это поведение, указав настраиваемый объект ViewEngine, наследующий от RazorViewEngine
, и добавив места для поиска просмотров.
От Make ASP.NET MVC 3 Razor View Engine ignore .vbhtml files:
public class CSRazorViewEngine : RazorViewEngine {
public CSRazorViewEngine() {
base.AreaViewLocationFormats = new string[] {
"~/Areas/{2}/Views/{1}/{0}.cshtml",
"~/Areas/{2}/Views/Shared/{0}.cshtml",
"~/Areas/{2}/Views/{1}/{0}.html",
"~/Areas/{2}/Views/Shared/{0}.html",
};
base.AreaMasterLocationFormats = new string[] {
"~/Areas/{2}/Views/{1}/{0}.cshtml",
"~/Areas/{2}/Views/Shared/{0}.cshtml",
"~/Areas/{2}/Views/{1}/{0}.html",
"~/Areas/{2}/Views/Shared/{0}.html",
};
base.AreaPartialViewLocationFormats = new string[] {
"~/Areas/{2}/Views/{1}/{0}.cshtml",
"~/Areas/{2}/Views/Shared/{0}.cshtml",
"~/Areas/{2}/Views/{1}/{0}.html",
"~/Areas/{2}/Views/Shared/{0}.html",
};
base.ViewLocationFormats = new string[] {
"~/Views/{1}/{0}.cshtml",
"~/Views/Shared/{0}.cshtml",
"~/Views/{1}/{0}.html",
"~/Views/Shared/{0}.html",
};
base.PartialViewLocationFormats = new string[] {
"~/Views/{1}/{0}.cshtml",
"~/Views/Shared/{0}.cshtml",
"~/Views/{1}/{0}.html",
"~/Views/Shared/{0}.html",
};
base.MasterLocationFormats = new string[] {
"~/Views/{1}/{0}.cshtml",
"~/Views/Shared/{0}.cshtml",
"~/Views/{1}/{0}.html",
"~/Views/Shared/{0}.html",
};
base.FileExtensions = new[]
{
"cshtml",
"html",
};
}
}
Затем зарегистрировать его в вашем Application_Start()
:
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new CSRazorViewEngine());
Или просто add .cshtml
to your Webstorm's configuration as File Type HTML.
. Конфигурация webstorm решила мою проблему – daniel
Cant webstorm обрабатывает cshtml ?! Или вы не можете установить флаг, чтобы сказать, что cshtml относится так же, как html ?! –
Определите «процесс». Можете ли вы показать соответствующий код, как вы хотите это использовать? – CodeCaster
по процессу Я имею в виду, что включен встроенный код строки C#. Webstorm не анализирует .cshtml – daniel