MVC :: External Assembly For Controllers

Aug 24, 2010

I would like to have a project that contains all of my Controller logic. I'm not concerned with using Areas, as these are still maintained within the same project. Consider this scenario: I have multiple sites/apps that require the exact same interaction in regards to a particular area, say CRUD ops on a user account. I do not want to create all of the controller logic for one site/app, recreate it again for the next, and make sure that I keep all maintenance to each in sync. I would prefer to keep the controllers in a separate project and reference them from the appropriate site.

I know someone will say that the controller logic is a lot of times specific to the application (as I've read elsewhere), but let's just say that it is guaranteed to be the same. I want to focus on the "how" and not the "why". So far, I've created a class library project with the appropriate references for accessing System.Web.Mvc. How do I proceed with the routing configuration for this? Is this idea even possible? I read a few older articles that were written when Areas were first being introduced that said to create separate projects for them. Is this idea similar to that?

View 2 Replies


Similar Messages:

How To Use Areas With Controllers From A Different Assembly

Jan 29, 2011

I'm starting a new ASP.NET MVC project, and I decided to put my controllers in a different assembly. Evertyhing works fine, but I have hit a problem: I created a new area in my MVC Project, called Administration. I have an AdminController Class in my seperate assembly which is supposed to return views from my Admin area, but everytime it tries to return a view, it looks for it in the wrong place (~/Admin/SomeView.cshtml Instead of ~/Administration/Admin/SomeView.cshtml) How can I tell the controller to look for views in the wanted area?

View 1 Replies

MVC :: Move Controllers/Models Into A New Project/Assembly?

Oct 6, 2010

I have to admit first, that for the last few years, I've been mostly an MVP guy versus MVC. However, how I used to implement MVP is very similar to how MVC 2 is now implemented. I only have one issue with it...When I used to create MVP apps, I could put all my logic (presenters, models) into separate assemblies/projects in the solution and my views into the main web app. This allows me to change the UI (i.e. the web based UI) to something else like a smart client or Silverlight or whatever and still have everything just work. With MVC 2, everything is all in the same project: controllers, views, models. Areas looked like a good start, but ultimately, not what I was looking for.So, here's my question... How do I move the controllers and models out of the web project and into their own projects and still have everything work? A good, simple example would be the default MVC 2 web application template. When you open a new (non-empty) MVC web application, it creates a basic site for you. From there, how could I move the controllers and models in separate projects and still have everything just work? I can't seem to find anything on this anywhere else which has brought me here

View 13 Replies

Access ASP Rolesprovider From External Assembly

Jan 14, 2011

I have a RolesProvider properly registered and fuctioning. When the ASPX-page is executed I do some of the work in external assemblies (.dll-files referenced in, plain vanilla). I need to access methods on this role provider from the external assembly. How can I do that?

Note: I don't want to pass a reference from ASPX to the external class if possible. Something like "HttpContext.Current.Roles" would be great. Bonus: Shed some light on when and how is the custom ASP.Net RoleProvider used.

View 1 Replies

Recompile The Assembly To Use The New Mono Assembly Versions The Assembly Is Closed Source?

Feb 18, 2010

I have recently discovered that I am affected by this bug http://www.mail-archive.com/mono-bugs@lists.ximian.com/msg71515.html

Well,at http://www.mail-archive.com/mono-bugs@lists.ximian.com/msg71529.html they say the work around is to create a global policy assembly and redirect the assemblies that way since it is not read from the web.config.

How do you actually do what they describe there? There is a huge documentation gap in that area with Mono.Also,I can't just recompile the assembly to use the new Mono assembly versions because the assembly is closed source.(but it does work with Mono.)

View 1 Replies

Visual Studio :: Assembly Editor - Create A First Blank Page For An Assembly Project?

Oct 11, 2010

i was wondering if visual studio 2010 can be used as an assembly editor too????if yes where do i have to go to create a first blank page for an assembly project?

View 1 Replies

Web Forms :: Referring An Assembly In Project / Without Adding Assembly Reference, It Still Accepting And Running Code?

Jul 5, 2010

Before using any class in your website project/page we have to add it's assembly reference to our project. Right?

Now, when I am using SmtpClient class from System.Net assembly after adding the System.Net.Mail namespace in namespace node of application's web.config file but without adding assembly reference to the project, it still accepting and running the code. Why?

I enquired the machine's web.config file located at C:WINDOWSMicrosoft.NETFrameworkv2.0.50727CONFIG but didnt find assembly reference for System.Net there also.

So bit confused how it is working and where the assembly reference has been added and how?

View 1 Replies

Assembly Generation - Reference Assembly Targets Different Processor?

May 2, 2010

I'm getting following warning

Assembly generation -- Referenced assembly 'System.Web.dll' targets a different processor

What does this mean and how do I fix this?

View 1 Replies

Create Shared Assembly And Use That Assembly In Web Application?

Jun 3, 2010

I just want to create Shared Assembly and use that assembly in our application.I am using VS 2005.

Step 1

I am trying to build a dll.

Create class library project <TestDllHell>.

Under that project add CalculationArea.cs file.

[Code]....

Then TestDllHell.dll add into GAC successfully.

Now I want to use it in my Website project so did the following steps but unable to view that dll in .Net Reference List Box.

•I go for Run regedit to edit the Windows Registry.

•Navigate to the HKEY_LOCAL_MACHINESOFTWAREMicrosoft.NETFrameworkAssemblyFolders key.

•Right click on the AssemblyFolders key, then select New > Key. Enter the name of your assembly (without the .dll extension).

•Double click on the key's (Default) value. The Edit String dialog will appear. Enter the full path of the folder where your assembly resides. Note that all assemblies in that folder will appear in the Visual Studio list.

•IMPORTANT! You must exit and restart Visual Studio to see your assembly in the Add Reference dialog.

My question is that

How can I get that dll in my add reference assembly List .Net section?

And if I modify that dll(TestDllHell.dll) then again register in GAC then version will be different,So how can I told my client application that which dll you choose?

View 3 Replies

Sub Areas To Group The Controllers?

Feb 17, 2011

Does the current MvcRouteHandler support something similar to Monorail's concept of an controller area? a way to group the controllers.

View 1 Replies

MVC Controllers Vs Proxy Layer?

Nov 25, 2010

i'm in a project with a service layer (WCF), a proxy layer that are between this service layer and the "controllers". Every controller should call this proxy layer to get data, and instead return a model to be rendered, returns a bigger entity that i've to convert using Linq to a more little model. Then pass it to the view.

Do you think is a good idea that this conversion be done by the controller? In my opinion the controller is not the responsable to shape the incoming object from the proxy layer. This object should be returned by the proxy layer and the controller should pass it to the view directly.

View 1 Replies

MVC :: Use Controllers To Get Data And Post?

Sep 12, 2010

I wounder if there are samples how to create Restful serivece withmvc. Or I can use MY controllers to get data and post data?

View 2 Replies

How To Unit Test Mvc 2.0 Controllers The Right Way

Jan 9, 2011

I want to test that when my form data is posted back to my controllers that the data annotations and the model binding is going to do its job and give the correct model state. After googling for a while I can't find a really good tutorial or article that shows how to do this.

Can anyone point me in the right direction? What is the best practice in this area? I have read that I may need to use moq and MVCContrib but I have not read a tutorial that makes me shout, "Yes, this is the right way to do it!"

View 1 Replies

MVC :: Want To Create Two Controllers/Paths?

Sep 16, 2010

I am wanting to create a path somewhat like this: /Administration/News and have it forward to a News controller instead of it being the action.How would I go about this?

View 3 Replies

MVC :: Difference Between Controllers And Webservices?

Aug 12, 2010

I was wondering what the major differences are between controllers and webservices. I understand webservices can receive postbacks via ajax while controllers cannot. Also, when you put a webservice in a MVC site, what file structure do you use to store it? Just create a single services folder?

View 4 Replies

Can't Get New Controllers Or Views To Work In .Net MVC

Apr 19, 2010

Basically what the title says. I created a new MVC application. I'm trying to add new pages to the site, but anytime I do I get the following error:Server Error in '/' Application.The resource cannot be found.Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

namespace MyAppMVC.Controllers
{
public class ProductsController : Controlle{
public ActionResult Index()
[code]...

View 3 Replies

MVC :: Handling Unknown Controllers?

Nov 1, 2010

I'm currently migrating a WebForms app over to MVC. One problem I have is that some users will probably have a page like www.mysite.com/login.aspx bookmarked (or maybe some other .aspx page). Currently this will throw an InvalidOperationException stating that the controller 'login.aspx' could not be found. Is there any way I can handle this so that it redirects the user to another page?

I know I can implement Application_Error in the Global.asax file, but I'd rather not redirect on any InvalidOperationException, just when it's an invalid controller.

View 5 Replies

MVC :: Subfolders Within Controllers Folder?

Feb 4, 2011

I am developing a restful web api using asp.net mvc and trying to extend the MVCWEBAPI project on codeplex that i took from here - http://code.msdn.microsoft.com/MvcWebAPII have added a folder nested within API folder inside the Controllers folder.This path does not work - (nested folder Security)http://localhost/API/Security/Authentication/LoginAlthoug, this path works - (not nested)http://localhost/API/Media/GetMediaThe folder structure is Controllers ->APIWithin API folder I added a Security folder and then added AuthenticationController under it.To make the routing work, I updated global.asax.csBelow is the required code.

public static void RegisterRoutes(RouteCollection routes)
{
var map = new NameValueCollection();

[code]...

View 2 Replies

MVC :: Correct Way For Creating Controllers?

Jan 27, 2010

I mean parameters of methods of controllers. For example, I have a View, which has :1. One radiobutton Yes / No (table inside DB has bit field)2. dropdownlist with int values (table has int too)3. Textbox (Firstname for example)I can create a method:

[Code]....

View 5 Replies

C# - Error Handling In Controllers With MVC?

May 4, 2010

Does it make sense to do error handling and logging inside actions methods or handle the OnException method inside the controllers. One way means writing try/catches in all the action methods even when there is nothing to be done to recover from the error. Handling this at the controller level would allow logging and redirection to an error handler page without writing try/catches inside all the action methods.

Which method makes the most sense? Here is example code of try/catches in an action method.

[HttpPost]
public ActionResult Delete(int id)
{[code]...

View 1 Replies

MVC :: Splitting The Views And Controllers?

Jan 20, 2010

For applications that need to have fastly different view layers, and I would like to still use the idea of the controller. I would ideally like to but the controllers in a Class Lib. and then have only the Views in a MVC Web Application. Taking the model out in this way works well, but I can't find a nice way to split the views and controllers.

View 7 Replies

MVC :: Navigate Between Controllers Using ActionLink?

Jan 14, 2010

[Code]....

Navigate between controllers using ActionLink in mvc2

View 2 Replies

C# - Controllers Action, Do Have To HttpContextBase?

Apr 10, 2010

From within my controllers action, do I have access to httpcontextbase?I have a method that takes httpcontextbase as a parameter.

View 1 Replies

MVC :: Copy The Fields Without Controllers?

Feb 18, 2011

How does this step in the MVC Views ?Without sending to Controllers

[Code]....

[Code]....

View 5 Replies

MVC :: Loading Controllers From WebService Context

Dec 30, 2010

I'm using the release 1 candidate from a few weeks ago and am loading my controllers from the spring.net context. I notice that my factory which couldn't be simpler keeps being called for a controller called "css". I'm using the Razor template engine. Does mvc or razor create any behind the scenes controllers that I don't know about?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved