asp.net-mvc

ASP.NET MVC Web application vs ASP.NET Web Application

Other than the fact that ASP.NET MVC Web Application has more clarity in its implementation of the MVC pattern and that it strictly follows the MVC pattern, how is it different from ASP.NET Web Application? If you make your ASP.NET Web Application have a Business Logic Layer, Data Access Layer and strictly make all data queries using th...

ASP.NET MVC routes

I need help with this route map routes.MapRoute("Blog_Archive", "Blog/Archive/{year}/{month}/{day}", new { controller = "Blog", action = "archive", year = "", month = "", day = "", ...

ASP.NET MVC and Ajax

From what I've read about ASP.NET MVC, it appears it requires posting to work, is there any working example (With source available) of a ASP.NET MVC website that has no postbacks with the help of Ajax? (I checked the related questions earlier but couldn't find what I was looking for) Thanks in advance. edit: I need jQuery solutions no...

How to Make ASP.NET MVC Recognize IHttpAsyncHandler from IRouteHandler.GetHttpHandler() ?

In this question & answer, I found one way to make ASP.NET MVC support asynchronous processing. However, I cannot make it work. Basically, the idea is to create a new implementation of IRouteHandler which has only one method GetHttpHandler. The GetHttpHandler method should return a IHttpAsyncHandler implementation instead of just IHttpH...

How can I get CheckBox to maintain checked state across postback in ASP.NET MVC?

I have an ASP.NET MVC project with a form. In the Action method that handles the POST verb I have a custom IModelBinder implementation that is binding the form data to my model instance. If there are errors I am using bindingContext.ModelState.SetAttemptedValue() and bindingContext.ModelState.AddModelError() to persist the submitted val...

Is it possible to trigger an HTTP DELETE request from an HTML form?

I have an ASP.NET MVC project and I have a single action that accepts GET, POST, and DELETE requests. Each type of request is filtered via attributes on my controllers Action methods. [ActionName(Constants.AdministrationGraphDashboardAction), AcceptVerbs(HttpVerbs.Post)] public ActionResult GraphAdd([ModelBinder(typeof (GraphDescriptor...

ASP.Net MVC and RenderPartial w/ relative paths

I've been playing around with ASP.NET MVC and had a question. Or maybe its a concern that I am doing this wrong. Just working on a lame site to stretch my wings a bit. I am sorry this question is not at all concise. Ok, here's the scenario. When the user visits home/index, the page should show a list of products and a list of articl...

Default modelbinding for enum in asp.net mvc?

I want a radio button generated with the Html.RadioButton() html helper to bind it's value to a field that has a struct as type. Less abstract: CommonProject.Services.SearchBag.Effects: public enum Effects { Any, Solid, Effect } In the strongly typed ViewData: public class SearchBag{ public Effects EffectIndicat...

Get originating port from ActionExecutingContext ?

Is it possible to get the originating port from an ActionExecutingContext object? If so, how? ...

Is it possible to make an ASP.NET MVC route based on a subdomain?

Is it possible to have an ASP.NET MVC route that uses subdomain information to determine its route? For example: user1.domain.com goes to one place user2.domain.com goes to another? Or, can I make it so both of these go to the same controller/action with a username parameter? ...

MVC LINQ to SQL Table Join Record Display

Hey all, Im having problems displaying records to my view when passing viewdata to a user control. This is only apparent for linq to sql objects where I am using table joins. The exception I receive is "Unable to cast object of type '<>f__AnonymousType410[System.String,System.Int32,System.Nullable1[System.DateTime],System.String,Syste...

How can I maintain ModelState with RedirectToAction?

How can I return the result of a different action or move the user to a different action if there is an error in my ModelState without losing my ModelState information? The scenario is; Delete action accepts a POST from a DELETE form rendered by my Index Action/View. If there is an error in the Delete I want to move the user back to th...

Cannot use local variable before it is declared ASP.NET MVC Beta

Hi, I have some code like this: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Save([Bind(Prefix="")]Person person) { String s = person.property; /* ... */ } But it throws the error: "Cannot use local variable 'person' before it is declared". What simple thing am I missing? ...

How to send an email with attachments using SmtpClient.SendAsync?

Hi, I am using a service component through ASP.NET MVC. I would like to send the email in a asynchronous way to let the user do other stuff without having to wait for the sending. When I send a message without attachments it works fine. When I send a message with at least one in-memory attachment it fails. So, I would like to know if ...

ASP.NET MVC with Entity Framework

I'm thinking it would be smart to setup the Entity object context in Application_BeginRequest, store it in Request.items, use it throughout the request and dispose it in Application_EndRequest. That way the context is always available and I can navigate the Entity Framework object graph in my views, lazy loading what I haven't already ea...

Nested Applications with ASP.NET MVC

I'm currently working on an asp.net-mvc content management system. It would be incredibly useful to be able to deploy nested applications e.g. /shop to have a separate app inside. Or even another instance of the cms. I've found some information around talking about limiting the inheritance of the web.config but I've no idea how this map...

ASP.Net MVC framework and databinding

Hi, I am having some trouble grasping some concepts behind the MVC framework. I am doing a very simple application which categorizes products. The Creation screen will simply use a dropdown list showing the list of categories, the name of the product and submit. On a normal .Net app, I would databind a server dropdownlist in the Page_...

SessionID keeps changing in ASP.NET MVC why?

I am trying to keep track of something and using the SessionID as they key to that object However the SessionID every 2-3 reqiests changes shouldn't it remain the same? HttpContext.Session.SessionID Is the code I am using. ...

Nested views - how to access from the controller?

In my admin view I would like several sub directories for example: admin/users/list.aspx I also have: admin/list.aspx What is the correct code to access admin/users/list.aspx from the controller? Or should the admin sub directories be at root level of View/ and then use routing? ...

ASP.NET MVC one route, two different views

Hi Folks, I'm trying to design a homepage for an MVC site that has two different views, based on if the user is logged in or not. So image the default (not logged in) view is showing general, nonspecific info. If i'm logged in, the view is showing mostly personal stuff instead. What's the best practice to handling this? Don't forget, ...