Skip to content

Instantly share code, notes, and snippets.


Scott Sauber scottsauber

View GitHub Profile
View FeatureLocationExpander.cs
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Razor;
namespace FeatureFolderStructureDemo.StartupCustomizations
public class FeatureLocationExpander : IViewLocationExpander
public void PopulateValues(ViewLocationExpanderContext context)
// Don't need anything here, but required by the interface
View PartOfStartup.cs
// Include this after .AddMvc under ConfigureServices in Startup.cs
services.Configure<RazorViewEngineOptions>(options =>
options.ViewLocationExpanders.Add(new FeatureLocationExpander());
View Area vs Feature Folders
Areas seem to be like this out of the box:
Not like this, which is more like Feature Folders:
View NavigateTo In Extension
var dte = (DTE2) ServiceProvider.GetService(typeof (DTE));
dte.ExecuteCommand("Edit.NavigateTo", "Something.cs");
// this results in a blank NavigateTo window opening
View Index.cshtml
<div is-visible="User.Identity.IsAuthenticated">
This should only be visible if you're logged in
View Index.cshtml
@if (User.Identity.IsAuthenticated)
This should only be visible if you're logged in
View VisibilityTagHelper.cs
// Add more target elements here on a new line if you want to target more than just div. Example: [HtmlTargetElement("a")] to hide/show links
public class VisibilityTagHelper : TagHelper
// default to true otherwise all existing target elements will not be shown, because bool's default to false
public bool IsVisible { get; set; } = true;
// You only need one of these Process methods, but just showing the sync and async versions
public override void Process(TagHelperContext context, TagHelperOutput output)
View _ViewImports.cshtml
@addTagHelper *, WebApplication1
View polyfillFetch.js
window.Promise || document.write('<script src=""></script>')
window.fetch || document.write('<script src=""></script>')
View jqueryFallback.cshtml
<script src=""