Questions tagged [asp.net-mvc-3]

ASP.NET MVC 3 is the third major version of Model-View-Controller extension for developing web applications in a .NET framework.

ASP.NET MVC 3 is the third major version of the ASP.NET Model-View-Controller platform for web applications.

It supports the following new features:

Demos and Tutorials:

  1. Intro to ASP.NET MVC 3 (VB)
  2. Intro to ASP.NET MVC 3 (C#)

References:

See for more information.

38473 questions
15
votes
3 answers

Return html string from controller and display in view

How can I return a model with a string propertie containing
  • elements and display it in view? If I just write @Model.Messages it shows all the string.. i need it in html format.
  • MuriloKunze
    • 15,195
    • 17
    • 54
    • 82
    15
    votes
    3 answers

    asp.net mvc 3 razor get one element from IEnumerable

    I my view model(LIST) looks like this: public class ConversationModel { public int ID { get; set; } public string Body { get; set; } public DateTime Datetime { get; set; } public string Username { get; set; } …
    Irakli Lekishvili
    • 33,492
    • 33
    • 111
    • 169
    15
    votes
    2 answers

    How can my code find if it's running inside IIS?

    My C# code may be running inside an MVC3 application under IIS (currently 7.5, but I'd like to not depend on a specific version) or elsewhere. Looks like one way to know that code is running under IIS is to check the current process name, but this…
    sharptooth
    • 167,383
    • 100
    • 513
    • 979
    15
    votes
    2 answers

    How to resolve Autofac InstancePerHttpRequest

    I have registered a component like this in my Global.asax.cs: ContainerBuilder builder = new…
    Brendan Vogt
    • 25,678
    • 37
    • 146
    • 234
    14
    votes
    3 answers

    MVC 3 client side validation, model binding decimal value and culture (different decimal separator)

    I am trying to have my client side validation (model binding) to support different cultures, and I found an interesting blog on the subject on which I am trying to…
    Kman
    • 4,809
    • 7
    • 38
    • 62
    14
    votes
    2 answers

    DropDownListFor - does not select "Selected" value

    Another one of these questions regarding DropDownListFor not selecting the "Selected" value. Here is code: Model: public class CreateEditAccountModel { [Required] [Display(Name = "Permission")] public int PermissionId { get; set; } …
    Dmitry Efimenko
    • 10,973
    • 7
    • 62
    • 79
    14
    votes
    2 answers

    Add Keys and Values to RouteData when using MVCContrib to unit test MVC 3 controllers and Views

    Okay so I am using MVCContrib TestHelper to unit test my controllers, which works great. Like so many people though, by unit test I really mean integration test here and I want to at least make sure my views render without error given the model…
    Amasuriel
    • 2,212
    • 3
    • 18
    • 25
    14
    votes
    4 answers

    Validate checkbox on the client with FluentValidation/MVC 3

    I am trying to validate if a check box is checked on the client using FluentValidation. I can't figure it our for the life of me. Can it be done using unobtrusive validation?
    Sam
    • 15,336
    • 25
    • 85
    • 148
    14
    votes
    3 answers

    Advantages of razor replace (@href)

    In the documentation of ASP.NET MVC says that you should do something like this when have a link in a view Subpage. The razor engine replaces @href("~/SubPage")to /Subpage. What is the advantage of do it this way…
    Ricardo Polo Jaramillo
    • 12,110
    • 13
    • 58
    • 83
    14
    votes
    1 answer

    displaying image from db in Razor/MVC3

    I have a table in the db, which has the following :- CountryID, CountryName, and CountryImage. Now I am trying to display the image in the index and I have the following in the View :- @if (item.Image != null) { …
    JMon
    • 3,387
    • 16
    • 63
    • 102
    14
    votes
    1 answer

    Where should I create the Unit of Work instance in an ASP.Net MVC 3 application?

    I have read as many of the posts on Stackoverflow as I can find with regards the use of a Unit of Work pattern within an ASP.Net MVC 3 application which includes a Business Layer. However, I still have a couple of questions with regards this topic…
    tcode
    • 5,055
    • 19
    • 65
    • 124
    14
    votes
    3 answers

    Possible Bug With ASP.NET MVC 3 Routing?

    Normally i wouldn't put a title like this in the question, but i'm pretty sure it's a bug (or by design?) I created a brand new ASP.NET MVC 3 Web Application. Then i went to the /Home/About page. The URL for this page…
    RPM1984
    • 72,246
    • 58
    • 225
    • 350
    14
    votes
    2 answers

    How to inject dependencies used for validation in .NET MVC3?

    We have quite a few validation methods that need to access repositories / database to do their work. So far we have been using the service locator pattern (albeit sparingly) to accomplish this in custom ValidationAttributes: public override bool…
    danludwig
    • 46,965
    • 25
    • 159
    • 237
    14
    votes
    3 answers

    Multiple types were found that match the controller named 'Home' - In two different Areas

    I have two areas in my project. Now when I run the program I get this error: Multiple types were found that match the controller named 'Home'. This can happen if the route that services this request ('{controller}/{action}/{id}') does not specify…
    fiberOptics
    • 6,955
    • 25
    • 70
    • 105
    14
    votes
    3 answers

    setting HttpContext.Current.User

    I am developing an asp.net mvc 3.0 application which has a simple authentication process. User fills a form which is sent to server by ajax call and gets response, but the problem here is that using the following method…
    Babak Fakhriloo
    • 2,076
    • 4
    • 44
    • 80