asp.net-mvc

ASP.NET MVC Html.BeginForm Problem

I have a partial view: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DomainModel.Entities.Product>" %> <div class="item"> <h3><%= Model.Name %></h3> <%= Model.Description %> <% using (Html.BeginForm("AddToCart", "Cart")) { %> <%= Html.Hidden("ProductID") %> <%= Html.Hidden("returnUrl", ...

Why is Chrome searching for my favicon.ico when I serve up a file from ASP.NET MVC?

I have a controller in MVC serving up images from a database. EDIT: This still happens if I serve up a file over completely standard means in MVC. Every time I request my image, Google Chrome also searches for my favicon.ico. To avoid unnecessary discussions about other things "I should also care about" let us assume I do not care for...

ASP.NET MVC being hosted at DiscountAsp.Net and using a domain pointer

I host a website on DiscountASP.NET and they have any option of adding a domain pointer for a separate domain using your same hosting account. Thus if the original site is abc.com you can purchase a domain pointer to xyz.com and both initially point to the same root location. Using the root for abc.com is OK, but when xyz.com is the addr...

How to integrate IoC Membership provider with ASP.NET MVC

I have a custom membership/roles provider that I use in my MVC controllers that I also want to have accessible to ASP.NET MVC, so I can use AuthorizationFilters, etc. Since so many people have implemented custom providers I imagine many people have done this but I haven't figured it out or found postings that address this problem specifi...

Should I use the Anti-XSS Security Runtime Engine in ASP.NET MVC?

I have been reading up on Anti-XSS Security Runtime Engine and it looks like a nice solution for web forms because it inspects controls via reflection and automatically encodes data where appropriate. However as I don't really use server side controls in ASP.NET MVC, it does not seem to be a viable solution for ASP.NET MVC. Is this corre...

Passing variable to Ajax.ActionLink OnSuccess, OnComplete, OnFailure, etc

I'd like to put a div on my master page that I can update from anywhere in my site with updates. i.e. "recorded updated", "there was an error", etc. I'm going to style the div differently depending on the type of update. "fail", "success", "info". Basic stuff so far. So I have several ActionLinks throughout the site and they display ...

Combining Multiple outputs in single view in asp.net MVC

I am looking to use asp.net MVC for new project. I looked at different examples at asp.net and over web. I still didn't get answer to , what is the best way to combine output of different models into a single view. For example my home page will contain catgories, locations, snapshots of recent posts. These will come from three different ...

ASP.NET MVC DefaultModelBinder with nested lists

I have a View with a table representing an employee's timesheet. Days across the top, projects down the side, with each day/project intersection containing two values for regular hours and overtime. The (simplified) class definitions for the page model are: public class TimesheetFormModel { public List<Project> Projects; // oth...

ASP.NET MVC and ORM Selection

We are getting ready to begin redevelopment of a large aging internal enterprise application. We have decided to use ASP.NET MVC, but under consideration is which Object Relational Mapping (ORM) to choose. There are of course a multitude of open source and paid ORM implementations available. However, NHibernate seems to hold the largest ...

ASP.Net MVC: So wait... The Default Route Parameter Has To Be Named id?

Has anyone else had this issue? I have to be doing something wrong. So I'm setting up a route for errors like this: routes.MapRoute ( "SharedError", "Shared/Error/{error}", new { error = "" } ); And calling like: return parentController.RedirectToRoute("SharedError", new RouteValueDictionary(new { error = errorMessage.ToString()...

Dynamic Controls in a Strongly Typed View (ASP.NET MVC)

Say i have the following: public class Person{ public int ID {get; set;} public string Name {get; set;} } public class Phone{ public int ID {get; set;} public string PhoneNumber {get; set;} } public Class AddEditViewModel{ public Person MyPerson{get; set;} public List MyPhones{get; set;} } I want to create a...

What's the equivalent syntax for this MVC view code in Spark?

I've got this code in an MVC project using the WebForms view engine and I'm trying to convert it over to Spark. How can I conditionally call a partial and pass it view data? <% if (UserService.IsAuthenticated && !Model.Post.IsDeleted) { %> <% Html.RenderPartial("Reply", new ReplyViewModel { Id=Model.Post.PostId, CssClass="respond" }...

ASP.NET MVC Helper Extension Method not rendering text as a control

Tried to create this Extension method. Works except that the helper is rendering text, not the control to the View when the page renders: I included using System.Web.Mvc.Html; at the top of my helper class that contains this extension method so that it would understand helper.RadioButton. public static string WriteTestControlToScreen(...

JQuery Ajax call gives 404 'Resource Not Found' Error but Normal URL Call is Fine

I have a weird problem when using JQuery call in my ASP.NET MVC project. I found that the Ajax call gives 404 ( resource not found error). But when I use the usual URL GET call, I can successfully call the server without any problem. Any idea why this is so? This my ASP.NET MVC code public class ViewRecordController: Controller { pub...

To use ViewData or not to use ViewData

I've been reading the Professional ASP.NET MVC 1.0 book as well as reading other sources talking about using ViewModel instead of ViewData from within your controllers to Views. But then I see so many examples of ViewData being used in scenarios that are tough where there's no other way but to get something from ViewData. But then I rea...

JQuery Ajax call gets resolved to the current Controller Folder, Instead of root Folder

I think I found something very weird in JQuery and ASP.NET MVC. As mentioned in this question, I have the following JQuery code: $(function() { $("#username").click(function() { $.getJSON("ViewRecord/GetSoftwareChoice", {username:'123'}, function(data) { alert(data); }); }); }); ViewRecord is the controlle...

Accessing Request.Cookies from a Controller Constructor

Hi folks, I am using the UserData Property of the FormsAuthenticationTicket to store some userspecific information. I have a HelperClass which deserializes this UserData into a custom Object for strongly-typed access. I have my controller setup as follows public class SomeController : Controller { private CookieData _cookieData; ...

MVC Models & Controllers where what to write

We have started using MVC framework and now we are bit confused where to write business-logic, in controllers or models? For the project we are going to use WCF layer as DAL. People have different views on Model & Controller, and think differently of writing business logic either in 'M' or 'C'. What is the best practice? I believe we...

Can we unit test View ('V') of MVC?

Duplicate: Unit Testing the Views? Is there any way to unit test View? I am sure that we can test Model & Controller but don't know how to unit test View? Is that worth testing View? ...

Strange jQuery problem

The jQuery below gets a partial view containing a html table of addresses. jqModal is then used to display the addresses, and a mouseover used to highlight an address. This works fine on my local machine. When I try running it from a server (Win 2008, IIS 7), the addresses are shown in jqModal but the higlighting fails to work. Also, thi...