I'm creating my first MVC.Net application and I find myself including @using Gideon.Core.Mvc;
on almost every page. Is it possible to add it by default to all pages?
In Asp.Net I'm able to add default stuff for controls to the web.config, hopefully it can be done for MVC.Net as well.
The default _ViewStart. cshtml is included in the Views folder. It can also be created in all other Views sub-folders. It is used to specify common settings for all the views under a folder and sub-folders where it is created.
Just change the Controller/Action names to your desired default. That should be the last route in the Routing Table. In MVC 5. if you have a form login, when you click login on the home page, it will then still redirect to Home controller , not your custom controller specified in the route.
cshtml files are razorpages or MVC views, they does not contain any C#-written client-side code. If you wan to do so, you must use JavaScript. However, a . razor file, also know as a Razor component, can have C# written in it and run on client's browser.
You can add them in the <system.web.webPages.razor>
section in Views/Web.config
.
Here is the default:
<system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="System.Web.Mvc.WebViewPage"> <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> </namespaces> </pages> </system.web.webPages.razor>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With