asp.net-mvc

Asp.Net MVC: Server Controls vs Html class to render controls?

What are the advantages of rendering a control like this: <% Html.RenderPartial("MyControl") %> or <%=Html.TextBox("txtName", Model.Name) %> over the web Forms style: <uc1:MyControl ID=MyControl runat=server /> I understand that performance can be one reason because no object needs to be created but having the possibility of callin...

ModelBinding in asp.net mvc Beta1

I converted my web application from preview 3 to beta1 and am now trying to put the new functions of the framework to use. One of them is ModelBinding. For this particular situation I created a class that is (for now) just a container of a bunch of simple-type properties. If I create a form with a bunch of textboxes, I want the framewor...

ASP.NET MVC can't find route programatically

Hi folks, I have the following one route, registered in my global.asax. routes.MapRoute( "Home", // Unique name "", // Root url new { controller = "Home", action = "Index", tag = string.Empty, page = 1 } ); kewl. when i start the site, it correctly picks up this route. Now, when i try to programatically do the f...

ASP.NET MVC: Redirecting back to page when no parameter is given to URL

http://localhost:50034/Admin/Delete/723 Always needs this parameter to perform the action, however, if you go to the URL without the parameter, an exception occurs. How do you handle this and redirect back to the main page without doing anything? Thanks. ...

Intercepting requests in the ASP.NET MVC Framework...

Is it possible to intercept requests in the ASP.NET MVC Framework (beta 1) in order to interact and inspect them? I need to attach some logging and in some cases dynamically work out if the URL needs authorizing (like applying the Authorize attribute - but at run-time). ...

Tips from ASP.NET MVC and lessons for ASP.NET WebForms developers

What are some helpful things that ASP.NET MVC developers could suggest that would help us ASP.NET WebForms developers to write better code/web apps? I'm a WebForms guy but with all the new hype around MVC I'd value some comments on helpful tips, tricks and strategies that might be able to be used in a webforms app. ...

Resolve FilterAttributes On Controller And Action

I would like to do this: [RequiresAuthentication(CompanyType.Client)] public class FooController { public ActionResult OnlyClientUsersCanDoThis() public ActionResult OnlyClientUsersCanDoThisToo() [RequiresAuthentication] public ActionResult AnyTypeOfUserCanDoThis() You can see why this won't work. On the thi...

Is there a benefit to using the HtmlHelper in MVC?

Is there a specific reason why I should be using the Html.CheckBox, Html.TextBox, etc methods instead of just manually writing the HTML? <%= Html.TextBox("uri") %> renders the following HTML <input type="text" value="" name="uri" id="uri"/> It guess it saves you a few key strokes but other than that. Is there a specific reason why...

ASP.NET MVC - Script Combine

The ASP.NET team released the script combining feature in 3.5 SP1 as detailed here http://www.asp.net/Learn/3.5-SP1/video-296.aspx. Is there a similar feature already for the MVC framework? If not, is this in scope or is it possible to somehow leverage the webforms capability in MVC? I see this site uses a custom jquery.package.master wh...

Including an anchor tag in an asp.net mvc Html.ActionLink

In ASP.NET MVC, I'm trying to create a link that includes an anchor tag (i.e., directing the user to a page, and a specific section of the page). The URL I am trying to create should look like the following: <a href="/category/subcategory/1#section12">Title for a section on the page</a> My routing is set up with the standard: route...

Which platform allows for more rapid development, ASP.NET webforms or MVC?

Are there any obvious productivity gains in developing using webforms or MVC? ...

Running ASP.NET MVC preview 3 apps on a box with the beta installed - how can I remove System.Web.Mvc from the GAC after installing ASP.NET MVC Beta?

I have an app built against MVC Preview 3 (referencing local copies of the MVC assemblies) that I'm trying to modify/test on a machine with the ASP.NET MVC beta installed. I am not interesting in updating this app to run against MVC beta yet - I just need to make a few small changes. It's failing with MissingMethodExceptions on RouteCo...

Clean way of having jquery includes with ASP.Net MVC

How have you guys handled working with jQuery includes <script type="text/javascript" src="jquery.js"></script> in Asp.Net MVC when working with partial views/view controls? Basically, I don't want to make the jquery include in the master page because I am not using jquery in all of my views, but I also want an easy way for a user c...

Implement Modal Dialog Box in ASP.NET MVC

Anyone have any experience creating a modal dialog box using AJAX and ASP.NET MVC? I am looking to create a Yes/Cancel confirmation dialog when a user deletes an item. In standard ASP.NET I could just use the ModalPopup extender, but I am not sure how to do this in MVC. Thanks ...

Best practices for project organization with ASP.NET MVC

I recently downloaded Rob Conery's excellent ASP.NET Storefront reference application and am finding it incredibly instructive. One question that comes to mind is where one should place the Model classes (and the Data classes upon which they depend). The MVC project template creates a Model folder. But it seems to me that I would be b...

Does ASP.NET MVC Framework support asynchronous page execution?

I'm learning ASP.NET MVC Framework, From some articles like this, it seems that MvcHandler has only Execute() implemented, there is no asynchronous API implemented. Actually, I don't think Controller has asynchronous API either. So, ASP.NET MVC doesn't support asynchronous programming? this could be a big hurdle to scalability if the we...

How can I get Html.CheckBox() as boolean during POST in custom IModelBinder?

I am using Html.CheckBox(). The resulting HTML is: <input id="IsMultiGraph" name="IsMultiGraph" value="true" type="checkbox"> <input name="IsMultiGraph" value="false" type="hidden"> On the server I have an Action which is accepting the form post information and using a custom IModelBinder to bind the form results to one of my models....

ASP.NET MVC on IIS 6 - wildcard mapping - the incoming request does not match any route

Hi, I have been trying to set up my Beta 1 MVC app on IIS 6 and cannot get it to run correctly. I have added a Wildcard mapping to the .net isapi DLL as suggested in other blog posts but get the following error when I access the root of the website: The incoming request does not match any route. .. [HttpException (0x80004005): The inco...

ASP.NET MVC AutoEventWireup required?

Hi Folks, when i create an aspx page, the header includes something like this:- <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Create.aspx.cs" Inherits="My.Mvc.Views.Blah" %> With ASP.NET MVC apps, do we: need to include this AutoEventWireUp attribute?...

How to return a View in MVC with URL like this http://localhost/admin#sayhi

Ok Here is the exact scenario: I have a view named Index I have a partial view (user control) named SayHi I have an AdminController which has an Action named SayHi which doesn't do anything else ViewData["Message"] = "Hi There!"; I am using ajax to load partial views from the Index.aspx so when I have the followinf url > http://lo...