Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I put common Methods in MVC application

Tags:

asp.net-mvc

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?

like image 312
Picflight Avatar asked Jun 25 '09 20:06

Picflight


People also ask

Can we use WCF in MVC?

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.

What is a good place to register routes in an 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.

How can you include scripts in an MVC application?

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.


1 Answers

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.

like image 132
tvanfosson Avatar answered Sep 19 '22 07:09

tvanfosson