asp.net-mvc

How to get VS 2008's Add New Project dialog to show me the MVC 2 project templates?

How do I get VS 2008 Professional Edition's Add New Project dialog box to show me the ASP.NET MVC 2 project type? It currently shows me only the MVC 1 project template (ASP.NET MVC Web Application). I have both versions of MVC installed. ...

Getting a EmailMessage Attachment via FileStreamResult

I have this code here where I retrieve an attachment from an Email Message that is on the Exchange Server using EWS Attachment attachment = message.Attachments.Single(att => att.ContentId == Request.QueryString["cid"]); attachment.Load(); FileAttachment fileAttachment = attachment as FileAttachment; ...

System.InvalidCastException: in ASP.NET MVC partial views

In the controller: public ActionResult Index() { ViewData["page"] = 0; return View(data); } public ActionResult More(long page = 0) { ViewData["page"] = page; return View(data); } So, I have two views: Index.aspx and More.aspx. I created a partial view (PartialView.ascx) that is used in both of the views. Inside the p...

How do I integrate a Silverlight DataGrid into an ASP.NET MVC View?

I'm new to Silverlight and I've used it to create a simple datagrid that I'd like to include as part of a view within an ASP.NET MVC View (while using the existing master page layout). What's the best way to do this? I haven't been able to find any examples... ...

manage 2 different Log In sections

Hi, I'm creating a site with 2 different sections (main site and admin) and both of them need authentication. I have the main section already created and it works fine using FormsAuthentication. now, how do I go about creating the admin section? Can I use FormsAuthentication again? thanks ...

Error while parsing a Json object

From my jQuery file, I call a function from my controller which returns a Json object, as below: [AcceptVerbs(HttpVerbs.Get)] public ActionResult MatrixTypes() { var matrix = Enum.PricingMatrixType(); return Json(matrix); } The call is made by the following function, I'm posting only ...

how to return different view from different method in controller in MVC

hello all, can anyone help me? senario is.. I have UserController(UC) and Browse View in MVC, In browse page I have three buttons and thats why i have written javascript to call perticular method in UC, now within UC I am sending data to Model (which is comming from View) and I am able to search from m...

Is the Nerddiner walk-through suitable for ASP.NET MVC 2?

I'm keen to teach myself ASP.NET MVC 2 (coming from a heavy embedded or rich GUI background). If have found the nerddiner walk-through but it is still for ASP.NET MVC 1. The codeplex downloads have been updated to MVC 2 but the link for the PDF goes back to the MVC 1 book. Is it even possible to follow the walk-through in MVC 2? If s...

When is it right to use ViewData instead of ViewModels?

Assuming you wanted to develop your Controllers so that you use a ViewModel to contain data for the Views you render, should all data be contained within the ViewModel? What conditions would it be ok to bypass the ViewModel? The reason I ask is I'm in a position where some of the code is using ViewData and some is using the ViewModel. I...

Can I pass an enum into a controller so the Model Binder binds it?

if so, how should i pass the parameter? would a string matching the enum name be ok? This would be handy if I was passing a dropdown box that matched enumerated items. It would be useful to use a solution presented in this answer if I could just as easily bind to the enum when I submit the data back. ...

Razor/CSHTML - Any Benefit over what we have?

Hello, Anyone out there using the new CSHTML pages feature and is finding that they prefer this new view engine syntax over the existing ASP.NET MVC default view engine or over web forms, and if so, why? What about CSHTML gives you an advantage over MVC or web forms, or vice versa? Just curious to hear people's take on it. Thanks. ...

The wrong of two ValidationSummaries gets updated (inside of a partial view)

In my little app I've a strongly typed partial view (the Login Form) this is rendered within the Masterpage, this looks as follows: <!-- Login Box --> <div class="login"> <div class="login-bg clearingfix"> <% Html.RenderPartial("LoginViewControl", Model); %> </div> </di...

ASP.Net MVC Nhibernate Session

When moving to MVC, and now IIS7, we started having issues in that our HTTP Module that opens and closes the ISession was called on every request (static files, etc.). I wanted to avoid doing a full rewrite of NH session management, so I implemented this code in my module, to filter out everything but requests going to the mvchandler: v...

Multiple Types of Auhtorizations in .NET MVC 2.0

I want to allow two types of authorization in my .NET MVC 2.0 app. One would be good old-fashion id/password (forms authentication) but I also want to be able to look at the header of the request page for an id/password as well. If that's provided, I want to authorize based upon that, by pass the form authentication and allow the user i...

Asp.Net MVC online tutorials

what are the best online tutorials available for ASP.NET MVC. ...

asp.net mvc output cache, can i cache a result that will be different for different users?

i have read a few different things, it sounds like output cache will not cache a different copy of results for each user. so if user A has 3 menus and user B only has access to 1 of them, then caching the view result would show all 3? how can i cache things for each user so that it's not shared? thanks! ...

How to resolve issue with image path when testing HtmlHelper?

I came across an issue when I was testing my HTML Helper. Basically I'm creating a grid with loads of rows, columns and different types of data in it. In the header there is also a image to notify the user what column the data is sorted by. However, when I'm writing my test now (way too late, but better late than never right?!), I get th...

Determine result type in OnException of controller

I'm working on an MVC.NET 2.0 project where I'm trying to put in some special error handling logic in the OnException method of the controller. Basically I want to be able to determine the result type of the controller method in which the unhandled exception was raised, so that I can return error data in a certain format dependent upon ...

Why can't I bind form data directly to action method parameter?

I have action method like that: public ActionResult Index(HttpPostedFileBase image, int variable) and form element like that: variable 1:<input type="text" name="variable" value="1234" /> when I start debugging I am getting following exception: The parameters dictionary contains a null entry for parameter 'variable' of non-nul...

About organisation of an asp mvc application

I'm starting a new web application that will be made of multiple parts or modules. My client want to be able to redistribute the application with a subset of modules to some other clients. I read about Areas in mvc2 which seems to be what i'm looking at. I would also like to develop those modules in side projects and have the right one b...