I am used to having static methods in the App_Code folder, this folder is no longer available in MVC template. These static methods I use all over the site.
How is it done in MVC, what is the best practice?
How do you call the common methods?
Since WCF service application and MVC application both are in the same solution, we have to build the Service first and then the MVC application in order to consume the service in MVC application.
Every MVC application must configure (register) at least one route configured by the MVC framework by default. You can register a route in RouteConfig class, which is in RouteConfig. cs under App_Start folder.
Go to Views -> Shared -> _Layout. cshtml file and add the render code. Make sure to register the custom javascript file after the jquery bundle since we are going to use jquery inside our js file. Otherwise we will get a jquery error and also register this before the script RenderSection.
Typically I will have one or more class library projects in the same solution to hold auxiliary classes. Create your classes in a class library project, then reference that project's DLL in your MVC web application. The exception to this would be any models, actual or view-only. These could be put in the Models folder.
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