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
14
votes
1 answer

Why does Url.IsLocalUrl return false if the URL contains a fragment?

I'm using Url.IsLocalUrl to check if the return URL passed to my authentication action is local or not. It works fine as long as there is no fragment in the URL. That is, /t/test-team-3/tasks/lists/15 returns true, but /t/test-team-3/tasks#/lists/15…
Ragesh
  • 2,800
  • 2
  • 25
  • 36
14
votes
2 answers

Unit Testing MVC Controllers

A controller in my ASP.NET MVC application pre-populates form data displayed by my view according to a couple of fairly straight forward rules. It seems like this would be a good thing to cover in my unit testing. But the only way I could see to…
Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
14
votes
2 answers

set a value to model using jQuery

How can I set a value to my model using jQuery? I have an input field (which its id="comment") and I want the text in it to be inserted into @Model.Comment using jQuery. something like: @Model.Comment = $("#comment").val();
ParPar
  • 7,355
  • 7
  • 43
  • 56
14
votes
2 answers

Service Layer Validation

I am trying to implement a validation strategy in my application. I have an MVC layer, Service layer, Repository and Domain POCOs. Now at the MVC layer, i use data annotations on my viewmodels to validate user input, allowing me to give the user…
James
  • 1,979
  • 5
  • 24
  • 52
14
votes
3 answers

The request URL is invalid in IIS 7

here is my…
Qudoos
  • 594
  • 1
  • 5
  • 12
14
votes
3 answers

Share enums between C# and Javascript in MVC Razor

I have seen this useful answer to a question for adding constants into a javascript file so it can be used with razor views: Share constants between C# and Javascript in MVC Razor I'd like to be able to do the same except define enums, but I'm not…
jaffa
  • 26,770
  • 50
  • 178
  • 289
14
votes
1 answer

How can I create a Html Helper like Html.BeginForm

I have an Extension Method that verifies if the user is able to see a portion of the webpage, based on a Role. If I simple remove the content, this brings me more work as all the missing forms will not be correctly registered upon save and I have to…
balexandre
  • 73,608
  • 45
  • 233
  • 342
14
votes
3 answers

PUT or DELETE verb in ASP.NET MVC on HTML form

I have a simple user registration form, with two fields, one for username and another for the password. I have a controller called UserController which has these two actions: [HttpGet] public ActionResult Register() { return…
Saeed Neamati
  • 35,341
  • 41
  • 136
  • 188
14
votes
5 answers

context.SaveChanges not working

My update method is not working in an ASP.NET MVC 3 application. I have used the following EF 4.1 code: [HttpPost] public ActionResult UpdateAccountDetails(Account account) { if (ModelState.IsValid) { service.SaveAccount(account); …
14
votes
5 answers

String concatenation with ASP.NET MVC3 Razor

i'm trying to concatenate a string in asp.net mvc 3 razor and i'm getting a little sintax problem with my cshtml. i what to generate an id for my checkboxes on a foreach statement, and my checkboxes should start with "chk" and what to cancatenate a…
Flavio CF Oliveira
  • 5,235
  • 13
  • 40
  • 63
14
votes
3 answers

MVC3 - Insert using ViewModel - Object reference not set to an instance of an object

I have got two models, seen below, and am trying to insert one of each to the database from one view. I have created a view model in an attempt to do this. public class Blog { public int BlogID { get; set; } public string Title { get; set;…
Michael Willmott
  • 529
  • 1
  • 8
  • 21
14
votes
1 answer

Call RenderSection twice ...?

I have an ASP.NET-MVC3-Layout and use the RenderSection function: @RenderSection("BackLink", required: false) How can I call this function twice? I want to render a defined section at multiple places in my layout. If I use @RenderSection() more…
Konrad
  • 4,329
  • 10
  • 54
  • 88
14
votes
3 answers

set "id" and "name" for @HtmlEditorFor?

I'm trying to set id and name for @Html.EditorFor, but this isn't working: @Html.EditorFor(model => model.value, new { @id = "testid1", @name="testname1"}) How do I set id and name?
Mariah
  • 727
  • 5
  • 12
  • 25
14
votes
4 answers

What does HTML.Raw do?

Is HTML.raw() specific to MVC? On what scenarios we have to use it? Can you please explain with an example.
KeenUser
  • 5,305
  • 14
  • 41
  • 62
14
votes
2 answers

Different models for Get and Post - MVC

As I understand from the question below it should be possible to use different models for Get and Post actions. But somehow I'm failing to achieve just that. What am I missing? Related question: Using two different Models in controller action for…
Rasmus
  • 2,783
  • 2
  • 33
  • 43