asp.net-mvc

Best practice entity validation in ASP.NET MVC & ADO.NET Entity Framework

Hi, i am using ASP.NET MVC & ADO.NET Entity Framework in a project. I want to add validation logic to my entities via partial classes. It works similar like shown in the NerdDinner.com ASP.NET MVC Application which is using LINQ2SQL. The main difference is, that i have to use the"OnPropertyChanging" event instead the "OnValidating" like...

Adding Redundant Information to a MVC Route

As you come to this question you'll notice the title of the question is in the address bar and the link you clicked on to get here. I am not sure the exact terminology so found it difficult to search for but how can I do something similar? That is, How can I add data to the address bar which is purely for show/search engines. Thanks ...

Fastest way to store a Large Set of Data (C# ASP.net)

A webservice i'm working with sends back a result set that equates to around 66980 lines of XML, .net returns this as a list object. As the user journey requires that we can reload this set if they step back a page, whats the fastest/best way of storing this result set per-user without slowing everything down. Ta -- many solutions: ht...

How to use the deny all with membership provider and MVC

I'm writing my first MVC app that uses the membership provider and I noticed that after I login and it is successful - it won't transfer me to the default url (and i can't view any url other than the logon view) so it appears i'm not actually authenticated for some odd reason. Here is part of the web.config - anything I might be doing w...

ASP.NET MVC - Testing Page to Model Binding

Hello, I have unit tests covering my model binders. I create a ModelBindingContext and populate the ValueProviderDictionary with my test values. I feel confident that once my controller gets the model, everything is covered with testing and the right things are happening. I also feel confident that if the BindingContext is correct my...

Which is more correct: using UpdateModel() or receiving a model as a parameter?

I've seen numerous examples of create actions in articles, books, and examples. It seem there are two prevalent styles. [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(FormCollection collection) { try { var contact = Contact.Create(); UpdateModel<Contact>(contact); contact.Save(); ...

ASP.NET MVC basic routing with no View name

This is a basic question about the routing machinery. From a new MVC project, I have this in the HomeController: public ActionResult MyPage() { return View(); } In the Views\Home folder, I have MyPage.aspx. The routing is still the default of {controller}/{action}/{id}. When I type in http://localhost:1790/Home/MyPage, it is corre...

Can't get search result for searching for ajax form

I try to creat list for detail view. then put a search text box on the top of the list. Hope the search result will replace the list partially. My control code like: public ActionResult Index(int? page) { Repository repository = new Repository(); var listitems= repository.FindAllItems(); return View(registry_page); } public Acti...

When to use ASP.NET MVC vs. ASP.NET Web Forms?

One of the common questions asked regarding ASP.NET MVC is why should you use it over ASP.NET Web Forms? The answer generally includes ViewState and clean URLs, amongst others. Towards the end you'll find a blurb about using the right tool for the job and that they serve different purposes. However, I don't believe I've ever seen what...

ASP.NET MVC Extension-Less URLS on Shared Hosting? (GoDaddy, etc.)

Is it possible to have extension-less URLs (ASP.NET MVC default) with shared hosting? I have seen some things to get GoDaddy working by including the .aspx extension in the Global.asax routing, however I don't want my URLs to include .aspx. ...

How to handle error from MVC controller on JqGrid inline editing.

onSelectRow: function(id) { if (id && id !== lastsel<%= count %>) { $j(gridName).restoreRow(lastsel<%= count %>); $j(gridName).editRow(id, true); lastsel<%= count %> = id; ...

MVC Newbie Question about Strongly-Typed Views

I think this is a namespace issue, and the answer is probably dead simple, but I'm new at this MVC stuff. I have multiple views named "Index." This was not a problem until I tried to create a new, strongly-typed view named "Index." (For what its worth, I'm trying to follow along with the steps in the NerdDinner sample, but in VB inste...

ControllerActionInvoker to invoke action with paramters

I use ControllerActionInvoker to invoke controller actions form unit tests var controllerInvoker = new ControllerActionInvoker(); var result = controllerInvoker.InvokeAction( testController.ControllerContext, "Default" ); How do i use it to call an action that has paramters? [AcceptVerbs( HttpVerbs.Post )] [ActionExc...

Asp.Net Mvc Can Not Log Out

Here is My Code To Log In var expire = DateTime.Now.AddDays(7); // Create a new ticket used for authentication var ticket = new FormsAuthenticationTicket( 1, // Ticket version username, // Username to be associated with this ticket DateTime.Now, // Date/time issued expire, // Date/time to...

asp.net mvc fckeditor upload image error

has anyone been able to get it to work with asp.net mvc ? changed the extension in config to .aspx there's a asp.net control as referred here http://forums.asp.net/t/1060019.aspx but haven't seen any asp.net control usage in mvc is it possible if there's no viewstate required ? anyone been able to configure fckeditor to uploading ima...

Handle multiple strongly typed objects in a controller

Not really a requirement or anything yet, but can you do this in a controller: public ActionResult Edit(IEnumerable<Contact> contacts) { //Loop through and save all records return View(); } This comes from wanting to have multiple records on a form, WITH NO GRID and submit all the items. The HTML would be similar to this <fo...

Exception handling opens error page inside current page

In my ASP.NET MVC app, I'm handling errors by overriding OnException in the controller. What is happening is that if a runtime error happens on the page, the Error.aspx page opens inside the page on which the error happened. Here's the code (with some extra error message stuff removed): Protected Overrides Sub OnException(ByVal filterCo...

How can I generate a complete trace.axd in ASP.NET MVC?

On my application, after enabling ASP.NET Tracing in an ASP.NET MVC application, the time calculation statistics were off by a factor of 5000. I have a page that is taking between 7 and 9 seconds to load. This is corroborated by both Firebug and the "time-taken" field in the IIS log files. (This is just the page returning to the client,...

DataContext crashes when unit testing

I am using Linq to SQL in my project. I have a part of the code that calls DataContext db = new DataContext() This works as expected when running the website however when calling this from within my unit test I get an error object not set to an instance... Do you know why this is? I know I should Mock the data context for testing bu...

ASP.NET MVC Best Pratices

I come from the WPF side of the world and I am used to using the MVVM pattern quite a bit. I am attempting to learn MVC and am having a little bit of dificulty trying to understand where my boundries are in MVC. Here is my scenario: I have 3 objects, Parent, Child and GrandChild. These are custom objects, not using the built in model...