asp.net-mvc

Why isn't MVC binding my nested collection?

Hello SO, If got a couple of linqTOsql objects that I am trying to edit through a form. First, there's the Stream class: [Table] public class Stream { [HiddenInput(DisplayValue = false)] [Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)] public long StreamID { get; set; } /*other propert...

ASP.NET MVC: Where should this business logic go?

I'm working on my first real MVC application and I'm trying to follow general OOP best practices. I'm refactoring some simple business logic that I had in a controller into my domain model. I've been doing some reading lately and it seems pretty clear that I should put the logic somewhere in a domain model entity class in order to avoid ...

If Facebook or Google had written via Microsoft Technologies, what would have happened.

I wonder, If Facebook or Google had written via Microsoft Technologies, what would have happened. Pros and cons? ...

How should I implement an MVC Bootstrapper for Unity and AutoMapper?

What is the best way to create a bootstrapper for my MVC 2 app? I'm using Unity and AutoMapper and want to abstract the loading and configuration of them as much as possible. A decent example is here (http://weblogs.asp.net/rashid/archive/2009/02/17/use-bootstrapper-in-your-asp-net-mvc-application-and-reduce-code-smell.aspx ), but Unit...

What is the difference between [AcceptVerbs(HttpVerbs.Post)] and [HttpPost]?

I can decorate an action either with the [AcceptVerbs(HttpVerbs.Post)]/[AcceptVerbs(HttpVerbs.Get)] [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(string title) { // Do Something... } or with the [HttpPost]/[HttpGet] attributes [HttpPost] public ActionResult Create(string title) { // Do Something... } Are they di...

How to use Jquery with MVC

I normally don't ask for help. I have spent 3 plus hours trying to incorporate simple javascript using JQuery with MVC app. Not a production app, I am just trying to learn MVC and JQuery. I have googled and found various sample apps that I couldn't get to work. so here is a detailed explanation of the latest download that I am trying to ...

How handle different results in an ajax call?

Suppose you have the following controller action [HttpPost] public ActionResult Save( CustomerModel model ) { if (!ModelState.IsValid) { //Invalid - redisplay form with errors return PartialView("Customer", model); } try { // // ...code to save the customer here... // return Pa...

Session issue when cookies are disabled in asp.net mvc

Whenever cookies are disabled in my browser and then i try to login on login page it unable to create session and so unable to login in system. Then i change the cookie setting to <sessionState cookieless="true" timeout="20" /> in my web.config and then try to login Post action of the login function it doesnt call and whenever i inpu...

ASP.NET MVC: How do I handle a view model with many properties?

So I have an almost 1:1 ratio of views to view models and things seem to be going well. If I understand their purpose correctly it seems that view models should "Strip down" Entity models so that only relevant properties are passed to the presentation layer Add additional information needed for presentation such as a list of state abbrev...

How to add meta tags on a master page for ASP.Net MVC 2

I have a master page currently with the below for the title: <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title> I've now realised I have to put meta tags in, would that be best done like so: <asp:ContentPlaceHolder ID="TitleContent" runat="server"> <title>Title</title> <meta name="Description" content=" ... ad...

Testing custom ModelBinder against HTTP context in ASP.NET MVC (1.0)

Hi, I'm trying to unit test a custom model binder - specifically, I want to see how it responds to various (possibly conflicting) values being submitted in the Request.Form and Request.QueryString collections - i.e. if I submit one value in the form and another in the querystring (yeah, yeah, I know, this is evil, but I want test covera...

ASP.NET MVC/EF: How should I handle navigation properties on a new Entity?

My particular application is an ASP.NET MVC app using Entity Framework. I have an object Entity0 which contains a reference (* to 1) to Entity1... public class Entity_0 { public int ID { get; set; } public int Entity_1_ID { get; set; } public Entity_1 Entity_1 { get; set; } } I also have some logic in Entity_0, however th...

Is there a list of "potentially dangerous Request.Path" values?

I want to generate slugs for my pages. To that end, I want to remove all the "dangerous request paths". Is there a list anywhere, or is there a way to find out? Thanks in advance. ...

Running code on page loaded?

Hi, I have a MVC view that contains some dropdowns like this : <%: Html.DropDownListFor(model => model.CS.C1, Model.CS.Category1List, "-- Välj kategori --")%> <%: Html.DropDownListFor(model => model.CS.C2, Model.CS.Category2List, "-- Välj kategori --")%> <%: Html.DropDownListFor(model => model.CS.C3, Model.CS.C...

ASP.NET MVC Validationsummary with excludePropertyErrors = true renders empty if the model is invalid

Say you have a standard ValidationSummary: <%: Html.ValidationSummary(excludePropertyErrors: true) %> If the ModelState contains model errors for properties but not for the model itself the ValidationSummary renders the following HTML: <div class="validation-summary-errors"><ul><li style="display:none"></li></ul></div> Which is dis...

Updating Linq2Sql object gives exception in MVC

Hi I have a asp.net MVC Web Application. I have a database where i have made my model, i use Linq2SQL to build my Business Logic Layer. In my application i have a customer object, when i call my "editCystomer" page i pass in a Customer to populate the textBoxes: [AcceptVerbs(HttpVerbs.Get)] [Authorize] public ViewResult ...

How to serialize IList<object> to string

Having an IList<NameValue> nameValueList, I need to convert that list to string for sending to aspx file as json. But because this happens in a project that does not have reference to system.web.script or system.web.mvc, i should use another way to serialize the IList NameValue is an object that have 2 public properties (name and value)...

ASP.Net MVC Recaptcha and Strict Doctype

I am using this this Recaptcha approach in my MVC project however it does not validate to Strict 1.0 DOCTYPE. Can anyone help? Thanks ...

N2 for MVC - how to get Zones working?

I'm looking at the N2 CMS Minimal Example for MVC (from here) I've figured out most of it, but I see that N2 supports 'Parts' that you can drop into 'Zones'. How do I get Zones and Parts working in the minimal example? The Html.Zone() command doesn't seem to work out-of-the-box. ...

Pass Array from MVC to javascript?

Hi, I can pass a variable from MVC ASP.NET by using this : var lastCategoryId = '<%=Model.CS.LastSelectedCategory %>'; This work fine with string or integer but how do I do with an array of strings? I have tried to pass the array the same way but the variable is set to System.String[] ? BestRegards ...