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


Similar Messages:

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 :: Views And Controllers Events Linked?

Jan 7, 2010

I am new to MVC. my question is when we add a view to the controller event by doing the right click and add view.then we give a view name and click on add button. where is this information stored that which view is linked to which view?

View 2 Replies

MVC :: Storing Controllers & Views In Separate Assemblies?

Apr 14, 2010

I'm building a CMS type of application in MVC. I want to reuse my views and controllers for adding/managing content in at least two other MVC sites. Obviously I dont want more than one code base for the CMS stuff. I figured out a way to do so:

Controllers:

Controllers are easy. Nothing more than creating a new Class Library Project and adding your controllers. Be sure to reference System.Web.MVC. In your MVC project just reference your controller assembly.

Views:

Views are a bit trickier. My solution was to add the folder structure to my assembly

CMSViews
CMSViewsWhatever

Then start adding my view pages. For each page, you have to set the 'Copy to Output Directory' to 'Copy Always' (right click -> properties)

Then I created a new class which inherits from 'WebFormViewEngine'. In the constructor I call the base() and then I add paths to the base.MasterLocationFormats and base.ViewLocationFormats to specify the new locations to look for views.

[Code]....

Setup in MVC project:

To get the controllers and views to work from the assemblies, you have to add two lines of code in the global.asax. Under the RegisterRoutes() method, add

ControllerBuilder.Current.DefaultNamespaces.Add("YourAssemblyNamespace.Controllers");
then under the Application_Start() method add:
ViewEngines.Engines.Add(new YourAssemblyNamespace.MyViewEngine());

What I dont like is that the Views get put into the Bin directory when published and you have to make sure to set the Ouput to Copy Always which is going to be a PITA for larger projects with lots of views.

View 1 Replies

C# - Attaching Validation To EF Objects Used In MVC Controllers/views?

Feb 11, 2011

We're throwing together a quick project (CRUD forms) and decided to skip view models and use EF entities directly in controllers and views. Since I'm not used to this approach, I'm confused about handling validation.

For example: a DB field has a length of 25. How does that get transferred (if it can) to a validation constraint in my view? If i was using an intermediate model, I would attach attributes to the model properties and it would work. How would I do this using EF objects directly?

View 3 Replies

C# - MVC Routing: Change Views For All Controllers In A Directory?

Jan 15, 2011

I have a subdirectory in Controllers named Admin, which contains several controllers.

Is there a way to change the route so that I can put all the views in "/Admin" for every controller in the Admin directory? Or do I need to map a route for every single controller?

View 1 Replies

Host .NET MVC Controllers+views Within A Webforms Project?

Jan 20, 2010

We have a legacy ASP.NET webforms application that we're engaged in stabilising and removing technical debt from. Is it possible to take a hybrid approach - ie, can ASP.NET MVC coexist with webforms within the same web-project? Are there any gotchas for that? If it is possible, I assume one just has to initialise the routes table, register the ASP.NET MVC handlers,

View 1 Replies

Grant Access To Controllers / Views For Non-authenticated Users?

Feb 3, 2011

I have an MVC 3 application which uses asp.net authentication. I have just created a custom errors controller and a couple of views for unknown errors and 404's. This works fine when I am logged into the application but if an internal server error happens during logon I would like to display the error/unknown view. However I just keep getting redirected back to the login as I am not authenticated.

I have added a location path for 'Views/Error' to my Web.config to allow access to all users but I am guessing it's the controller access that is causing the redirection.

Is there any way you can allow this in MVC or do I need to think of another solution? Just did not want to add a generic message to the login page as that's what my unknown error view is for.

View 2 Replies

MVC :: UML Class Diagram For Application Include All The Controllers And Views And Their Relationships?

Mar 16, 2011

I would like to ask a plain and simple question about the Model-View-Controller architecture - should the UML Class diagram for my application include all the controllers and views and their relationships, or should it just include my model classes, i.e. the entities that are the heart of the application, you know - like in an ordinary application - i.e. User, Administrator, Student, Teacher, Course, Grade etc...?

View 1 Replies

Php - MVC Architecture Decision - Refactor Existing Approach Into Controllers / Views And Database Access

Feb 12, 2011

Consider the following scenario: Page written in classic ASP or PHP, which is rendering a data report (series of HTML tables for simplicity). There is one main database query and then multiple sub queries as the page renders. The report is split into sub panels, which correlate to a sub query. Therefore:

Main database query. Loop over result. For each row, execute sub query and render report panel. How would you architect a similar report using the MVC pattern? This can be split into two parts: Efficiency at database level of multiple queries, which are dependent on values from an outer query. If all data was processed and prepared in the controller, would this also be deemed inefficient if looping within the controller and then again in a view to render. Could sub controllers be used or sub panels, which encapsulate smaller sections of logic i.e. loading data and rendering report panel.

View 2 Replies

C# - Transferring Info In A ViewModel Between Views And Controllers In MVC 2 Site Without Allowing Modification Of Info?

Jul 22, 2010

I'm building an ASP.NET MVC 2 site where I'm currently implementing an OpenID sign-up form. Unfortunately, I'm foreseeing a possible security bug/vulnerability inside my architecture.

Here's how I want OpenID login to work:

User requests /Account/Login, Controller sends back OpenIDLogin View. User enters their OpenID into the View, then OpenID authorization takes place, and finally the OpenID is returned to the Controller.The Controller checks whether the OpenID is currently in use by a user in the system or not. If it is, the user is logged in to that account. If not, the registration process begins.

And now, the OpenID registration process:

The OpenID identifier, as well as any other information provided by the OpenID provider (such as email address or name), is put into my custom ViewModel and sent to my OpenIDRegistrationForm View.The RegistrationForm View stores the OpenID in a hidden field to make sure that it gets sent back to the Controller.The user fills in the RegistrationForm View and sends it back to the Controller.The Controller creates the user account and puts the OpenID into the database.


The bug that I see within my architecture is that a user could modify the hidden value in the RegistrationForm View. Thus, they could spoof their OpenID! I will make sure to add another round of checking to the final Registration Controller Action to make sure that the OpenID that is provided doesn't exist yet, but there is still a possibility for spoofing. Can my architecture be improved somehow? I don't want this to end badly...

One solution I'm considering is encrypting the OpenID before I send it to the View and then decrypting it when it reaches the Controller. Should I try this?

View 1 Replies

MVC :: Routing - Seperate Controllers With Seperate Views ?

Apr 29, 2010

Here is what i would like to be able to do with the urls/routes:

1) www.domain.com/customer/home/index

2) www.domain.com/home/index

Where both the home controllers should be seperate controllers with seperate views and the company part should be an param for all the actions in the controllers.Now why i want to be able to do this is because of the following scenario: Each customer will have there own pages (which actually will all be the same for each customer but with different information per customer). The one without the customer is the general website where non customers can go to to become an customer or get information about the services we provide for them, they can sign up etc.

View 5 Replies

JQuery Events Don't Work With MVC Partial Views?

Feb 3, 2010

I am trying to get JQuery events to work with partial views in ASP.NET MVC. However, after you load a partial view through Ajax, JQuery seems not able to fire events for any of the elements in the partial view. I suspect that this issue will also happen if you are using other frameworks or JavaScript libraries to load partial html code with Ajax.

For instance, consider the following example:

Controller:

[Code]....

Once the page loads for the first time, you can click on the "Click here to display a Javascript message" and you will get a Javascript alert message that says "button clicked". However, once you click on the "Click here to load partial view", clicking on the button that is supposed to bring the Javascript alert message doesn't have any effect. It seems that the 'click' event is not being fired anymore.

why this issue occurs with JQuery and how to fix? This issue also occurs with other JQuery plugins that use events.

View 2 Replies

MVC :: Views Not Finding Assembly Reference In .NET 4.0 That Work In 3.5?

Apr 14, 2010

If I have a reference in my project to System.Data.Linq in an MVC application compiled against 3.5 I can use Linq to SQL generated entity objects in my views and access the foreign key entity sets. If I try and do the same thing in 4.0 I get the error messageCompiler Error Message: CS0012: The type 'System.Data.Linq.EntitySet`1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

View 1 Replies

Trace - Tracing Work In MVC2 Views?

Apr 29, 2010

I have a VS 2010 MVC2 .NET 4.0 web application. ASP.NET tracing is enabled both in the Page directive (Trace="true) and in the Web.config:

<trace enabled="true"
requestLimit="10"
pageOutput="true"

[code]...

View 1 Replies

MVC :: Create View With Partial Views But Submit Button Doesn't Work

Jan 11, 2011

i created a "create" view for creating a new record of my used model. The View includes partial views with the editor-fields. But the "Create" submit button doesn't work. When i copy the editor-fields to the create view without using partial views the submit button works. Here is my code: Create.cshtml

[Code]....

View 5 Replies

Fake Image Using .aspx Url To Track Email Views In Outlook, Doesn't Work

Apr 15, 2010

I have this in my HTML email to track if someone views the email in say Outlook.

<img src="http://www.example.com/track.ashx?user=3434" />

but this doesn't seem to work.Should I change my headers in the .ashx to server image headers? Can this work using this method?

I emailed myself with an email, other images displayed properly. There was no log in the database for the handler (the handler logs all requests to the db). Calling the URL to the file in the browser logs to the db, so its working.

View 2 Replies

Added 5 Views In The MultiView But All Views Are Tight Together?

Sep 28, 2010

I am learning MultiView control.Here are question:I added 5 views in the MultiView but all views are tight together. I can not drag and drop another control such as text boxes or labels into view area.

View 15 Replies

C# - .NET MVC Partial Views And Routing - Using Ajax Calls To Trigger A New Request But Non Of The Partial Views Are Refreshed

Mar 9, 2010

I have an MVC view that contains a number of partial views. These partial views are populated using partial requests so the controller for the view itself doesn't pass any data to them. Is it possible to reload the data in one of those partial views if an action was triggered in another? For example, one partial view has a jqGrid and I want to refresh the data in another partial view when a user selects a new row in this grid. Is there a code example for this scenario (in C#) that I can look at to see what am I doing wrong? I am using ajax calls to trigger a new request but non of the partial views are refreshed so I am not sure if the issue is with the routing, the controller,

View 1 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

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 :: 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







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