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.
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]...
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?
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.
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?
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?
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,
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.
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...?
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.
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?
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.
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.
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,
I'm using C# and ASP.NET 3.5. Basically I'm retrieving a column of data from a dataset and putting this into a list like so:
List<String> dates = new List<String>(); foreach (DataRow rowMonth in myDS.Tables[0].Rows) { string ListedMonthYear = (string)rowMonth[0]; dates.Add(ListedMonthYear); }
The returned values are:
Apr-10 Mar-10 Feb-10 Jan-10 Dec-09 Nov-09 Oct-09
I'm interested in splitting these values into two lists with the idea of performing operations on them in the future.
Apr | 2010 Mar | 2010 Feb | 2010 Jan | 2010 Dec | 2009 Nov | 2009 Oct | 2009
What is the best way to do so?
EDIT: rowMonth is just the datarow that includes all date related values - the month-year, the month beginning, month ending, month active or inactive. Basically I'm just trying to extract that first column month-year to do operations on and ignore the rest.
The following is an example of using session state, which i can handle with a single variable. But this example uses. well you can see it. Where I am stuck is splitting the string into the three variables. Also, I am not too sure about the ; vs. a comma delimiter that usually see. I think it is a pretty old example. Session("Stocks") = "MSFT; VRSN; GE" ' Get Stocks, split string, etc. Dim StockString StockString = Session("Stocks")
I am trying to get all the words in a string using a regular expression.When I use this expression in javascript, it works, but when I try it in the .Net code I get the whole string.this is my code.Is my regular expression wrong or am I using the wrong method?
Code: Dim myRegex As New Regex("/([a-zA-Z]){1,1}([a-z])+/g") Dim str() As String = myRegex.Split(text)
I am building an application using asp.net mvc, DI, IoC, TDD as a bit of a learning exercise.
For my data access I am using the repository pattern. Now I am looking at membership and how this can work with the repository pattern. I am currently using a Linq to Sql repository but don't want to be tied to SQL Server for membership.
Secondly, I am looking to split out membership into a number of services:
AuthenticationService - identify the user AuthorizationService - what can they do PersonalizationService - profile
The personalization service will be what really defines a "customer" in my application and each customer will have a unique id/username that ties back to the AuthenticationService - thus, allowing me to use the default ASP.NET Membership provider, roll my own or use something like Open ID.
Is this a good approach? I don't want to reinvent the wheel but would rather these important parts of my application follow the same patterns as the rest.
I am working with the listbox and binding the data to the listbox. My question is if i retrieve 20 rows in a listbox then how can i arrange 10 rows on each column (splitting 10 rows side by side or dividing). sample:
Exact Data in a Listbox Looking for something like this: Listboxitem1 Listboxitem1 Listboxitem3 Listboxitem2 Listboxitem2 Listboxitem4 Listboxitem3 Listboxitem4
I have one more question. How can I display my data in a listbox as a treeview structure with a nodes. Or can i insert treeview inside listbox.
I'm using the commandArgument property of the LinkButton ( Which is wrapped inside a repeater ) to pass two values -as one string- to a second repeater then I try to split them into two values, So I could use them as parameters in my ADO.NET Code (SqlCommand Parameters)....after testing my queries don't return any results but If I passed fixed values for the parameter or change the source of the parameter (just for test from a textbox or querystring or something) I get my results, so I think the problem is in splitting.
I Conduct some arugment values from the ArgumentCommand property of the LinkButton -which is wrapped inside a repeater:
I have too many lines in my code behind file. Now it grows up to almost 3500 lines. I wonder if it can be splitted into several files.
To be specify, say I have CustomerEdit.aspx and code behind as CustomerEdit.aspx.cs. In my code behind, most of them are functions taking care of UI (i.e. protected void ... _Click() or protected void ... _SelectedIndexChanged()). I have some private functions, but they usually refer to some UI elements.
Question: Can I safely seperate CustomerEdit.aspx.cs into smaller files like CustomerEdit01.aspx.cs, CustomerEdit02.aspx.cs, etc?
I have a large string that I want to save in a cookie, however I don't know what the best practices are for max string length per cookie, and max cookie count. What logic should I use to split the string and later combine a set of cookies?
(Microsoft ADFS and perhaps Siteminder do this technique so I would be interested in what thier implementation is)
First of all, I'm relatively new to asp.net (3.5) and all of its controls. What I'm trying to do is to split up a detailsview. I have a submission form containing quite a lot of fields that are supposed to be filled out by the user. In my design I have a tabstrip with headlines about the different sections of the form. For example:
Tab1: Personal Info Tab2: Info about your car Tab3: Contact info
I have tested to add a new "user" via a DetailsView and it works. But what I want to do is to split up the contents within the <Field> tags In the DetailsView In different div classes (using css and javascript to hide/show the right tab contents). But when I try to do this Visual Studio says that characters like <p> and others aren't allowed within the Field tags, which makes sense. Is there any control to use for these kinds of situations?