asp.net-mvc

RedirectToAction From ActionFilter

How-to access RedirectToAction from a custom ActionFilter ? public class ExceptionHandlingFilterAttribute : ActionFilterAttribute { public override void OnActionExecuted(ActionExecutedContext filterContext) { if (filterContext.Exception != null && !filterContext.ExceptionHandled) { filterContext.Excep...

TempData not persisting

Hi, I have a controller that sets TempData before returning a view, public ActionResult Edit(int id, int? order) { Route route = new Route(); // Do Work TempData["Route"] = route; return View(new FormViewModel(route, obj1, obj2)); } This view contians a partial view with a link which goes to another action method call...

ASP.Net MVC Custom Model Binding explanation

Is anyone aware of where I can find a tutorial for building a custom model binder. I have found several issues using the default model binder with EntitySets (not populating when creating new objects and creating duplicates on editing objects) and find that my UI doesn't match my model exactly (e.g. time fields formated "hh:mm am" do n...

asp.net mvc custom routes with multiple submit buttons

So I have a custom route as such: routes.MapRoute( "Wizard", // Route name "Wizard/{page}", // URL with parameters new { controller = "Wizard", action = "Index" } // Parameter defaults ); and have the following on my View: <% Html.BeginForm("Continue", "Wizard"); %> <input type="submit" value="Continue"...

How can I set a tabindex in a foreach loop in an ASP.NET MVC view?

How can I set the tabindex value of a set of checkboxes within a foreach loop in ASP.NET MVC? My current solution uses a Response.Write to output the checkboxes, but I'd rather find something more elegant. Does anyone have a good solution? This code does not work: <label for="country"> Country: </label> <%= Html.DropDownList("cou...

ASP.Net MVC - best way to identify returning user

Hi, I am developing an e-commerce app using asp.net mvc. After user successfully logged into system the application is pulling additional data from database (favorites, order history, unfinished cart etc.) What is the best way to pull that data in case if user used Remember me option? I am thinking to check if user is authenticated ...

MVC redirect problem

I'm implementing a class for all my controllers to inherit that will redirect to login page if user is not authenticated. The RedirectToAction line is not redirecting though. Can you plesae help correct? public class SecureController : Controller { public SecureController() { if (User == null || !User.Ide...

Should you use the method Application_Error in your global.asax in ASP.NET MVC?

I know that in ASP.NET people typically put a protected method called "Application_Error" in their global.asax file inorder to handle say, logging of exceptions. My question is, is this an ASP.NET only thing, or does it work equally well in ASP.NET MVC? Is it an ASP.NET MVC best practice or not? ...

Jquery or Basic XmlHttpRequest for MVC AJAX

Hi Getting JSON at client side via AJAX is something i am looking for in my ASP.NET MVC app. I found Jquery and basic XmlHttpRequest script for the purpose.I know the easiness with dom manipulation is one aspect for Jquery.But concerned with the file size of Jquery. But still cannot find Why i need to chose and study Jquery over the l...

VS2010 MVC and Entity Framework Model in Separate Project

Hi I'm experimenting with ASP.NET MVC in VS2010. I'm trying to use an Entity Framework model in a referenced project within the main MVC project. However, although I can manually create a view that can work with the EF Model in the other project, I can't use the in-built scaffolding features. Is there something I'm doing wrong? For re...

Edit Data in a Jquery Dialog

I have a page that lists records from a database call. I want to have an 'edit' link on each row that will popup a Jquery dialog so that the row can be edited. My question is how do I pass the data from the selected row to the jquery dialog box so that it can be edited? ...

How to access a user's saved DB data on an ASP.NET MVC page?

I know I can use the attribute [Authorize(Roles="client")] to make sure that only authenticated clients can access a page. But after that, how can I access this user's personal data? How do I programmatically get that user's account ID from that action controller? For example, on Stack Overflow, how does my personal account page access ...

ASP.NET MVC: Stack overflow error when calling Html.RenderPartial()

Hi everybody. I have a Controller called ActivationController with a LogOn action, which renders the view LogOn.aspx. LogOn.aspx renders a partial view called LogOn.ascx: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="Content1" ContentPlaceHolderID="T...

Problem with Ajax Click on Asp.Net MVC

I have a AJAX action link. On Click this posts to the controller. The controller sends back ascx view that is supposed to update a div in the original page. This works fine when running from WebDev server. However, in IIS environment, the original page is gone and the new view ends up showing on its own. Please help. Environment: II...

Is there a "Build Website" option for [MVC] Web Applications?

When working with the "Web Site" style ASP.NET project, VS.NET will compile all the ASPX/ASCX pages during the build process. This is great cause it validates all the embedded code. For most sites I don't have much, but with MVC I've got lots of <%= Html.Action(...) %> style snippets throughout. When refactoring the .CS files get updated...

Avoid "The class or CssClass value is not defined" Warnings in ASP.NET MVC ASCX Partial Views (UserControls)

Hello, I wondered how I can stop those annoying compiler warnings "The class or CssClass value is not defined" coming from my ASP.NET MVC partial views/ASCX user controls. The CSS is correctly defined, but the reference to the CSS file is obviously on the master page only. My partial views contain lots of CSS class references on div's et...

What is the Visual Studio Development Server equivalent of the Apache Access Log?

Coming from a PHP/Apache background I'm looking for the equivalent of the Access Log when I'm developing ASP.NET MVC applications in Visual Studio 2008. On the Unix box I'm used to tailing the access_log to get an real time view of which requests is send to the web server: tail -f access_log I'm currently looking into ASP.NET Traces. ...

ASP.Net MVC: RenderPartial for a static HTML file.

I'm sure this is an easy one for most of you ... What is the best way to inject static HTML (from a html file on disc) into a View? I want something along the lines of this: <%= Html.RenderPartial(pathToMyHtmlFile) %> ...

asp mvc with nvelocity?

I am trying use NVelocity with ASP.NET MVC, but I am having difficulty navigating the noise of out-of-date information. There are many broken links, incorrect info, etc. Is there a guide or howto that works with the current MVC and NVelocity API and distribution mechanisms? Tia, -neil ...

What would be an ASP.NET MVC route to a static Sitemap.xml?

If I want my url to look like, www.mysite.com/sitemap.xml, how would my route look in my Global.asax file? What is the simplest way for me to route and return that static Sitemap.xml file? ...