asp.net-mvc

Asp.net: pass client information

I'm building a website with asp.net mvc and there is some data that I need to consult with every browser request. This contains the clients date and its latitude/longitude. This way we can update the users (using a PDA) location. If we assume that I already have the latitude & longitude, how can I pass it to the webserver with every bro...

ASp.NET MVC 1.0 map route to subdirectory

How to I setup a route of the url /customer/export/billing to the controller Customer.ExportBilling() ? When I try this: routes.MapRoute( "exportCustomerBilling", "customer/export/billing", new { controller = "Customer", action = "ExportBilling" }); I get a 404, the controller method is not invoked. Using <%= Htm...

What is the lifetime of a ASP.NET MVC Controller?

I'm in the process of developing my MVC application and I was thinking, What is the lifetime of a controller class? When does it get created? How many instances of a single controller are there? what are the implications of local variables? when is it destroyed? I'm sure there is a good link somewhere floating around on the internet, b...

RedirectToRoute("Default") and Redirect(returnUrl) are returning '200' instead of '302'

Hi Guys I'm trying to use the following code to log users in: $("form").submit(function(event) { $.ajax({ type: "POST", url: $(this).attr("action"), data: $(this).serialize(), complete: function(XMLHttpRequest, textStatus) { if (XMLHttpRequest.status === 302) { ...

MVC Tutorial - Reference

Can you reference a good MVC tutorial? Thanks in advance. ...

MVC to MVC2 Errors

I've just updated to VS2010 (rc) and subsequently been forced to update my projects and convert to MVC2 (ta microsoft)... which has scuppered the first app its touched. Error 2 'System.Web.Mvc.IValueProvider' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'System.Web.Mvc...

ASP.NET MVC Hidden field not POSTing

With jquery autocomplete I have a hidden input field to store ID because the name gets inputted into the autocomplete field on select. Like this: $("#Clients").result(function (event, data, formatted) { if (data) { $("#ClientID").val(data["client_ClientNumber"]); if (data["ClientName"...

how can i do this with asp.net mvc routing ?

Is there a way to create a route like this "http://mysite/Username" ? ...

How do I bind multiple dropdowns in my ASP.NET MVC Edit Page?

I have a viewmodel that contains a number of properties, a SelectList, and an array of child objects. public class RoundViewModel { public int RoundId { get; set; } public string RoundName { get; set; } public SelectList Teams { get; private set; } public List<GameViewModel> Games { get; set; } } public class GameViewMo...

ASP.NET MVC OutputCache JSONP

I cache everything that is possible on an ASP.NET MVC website and it works perfect. Now I have created an API where the calls go to Controller Actions. (http://mysite.com/topics/latest.json) The API is able to return results in different formats (json, xml, rss). The data for returning is loaded in the Action: [ResponseFilter] public ...

Creating a large form with multiple dropdowns and text fields in ASP.NET MVC

In my continuing journey through ASP.NET MVC, I am now at the point where I need to render an edit/create form for an entity. My entity consists of enums and a few other models, created in a repository via LINQtoSQL. What I am struggling with right now is finding a decent way to render the edit/create forms which will contain a few dro...

How can I right-align my td elements in an MVC view using CSS?

I am creating an Index page in an MVC 1.0 application and want to right-align the text in one of the columns. I have tried to do this by creating an extra class in the td style and setting the "text-align: right" in this but this doesn't appear to be being applied to that element. In my CSS file I have: table td { padding: 5px; ...

Custom DateTime model binder in Asp.net MVC

I would like to write my own model binder for DateTime type. First of all I'd like to write a new attribute that I can attach to my model property like: [DateTimeFormat("d.M.yyyy")] public DateTime Birth { get; set,} This is the easy part. But the binder part is a bit more difficult. I would like to add a new model binder for type Dat...

Get "Default" Route Url in Controller

Hi Guys Can anyone tell me what is the syntax for retreiving the actual URL for the "Default" Route? I'd like to do something like: string url = RouteTable.Routes["Default"].ToString(); //(even though that code is completely wrong) so that I could have the url value of the route available to work with. So far, I've been trying the...

Forms Authentification with sqlite

Hi, I have an ASP MVC-application that uses a SQL server express for and Forms authentication. The server im using does not have enough memory to run SQL Server express stable and I was thinking about migrating to SQLite instead. Is it possible to just migrate the existing aspnetdb-database from SQL Server to SQLite so that all my user...

What kind of informations show when validation of AntiForgeryToken fails?

I have public site with some forms. Simple question: What kind of informations should I show when validation of AntiForgeryToken fails? Is it should be 404 (page not found), error or just ignore it and redirect to the home page? ...

jQuery .post() and dynamically specifying the return type

Hi Guys I have the following $.post() function that expects JSON as its return value. $.post($(this).attr("action"), $(this).serialize(), function(data) { if (data.returnData) { //do stuff with data.returnData } }, "json"); This piece of code does the trick so long as the return type is JSON. The question I ha...

Responding to REQUEST_METHOD = HEAD using ASP.NET MVC

I have an ASP.NET MVC site and ELMAH is showing me that my site is erroring when receiving an HTTP request with REQUEST_METHOD = HEAD. How do I respond to these requests using ASP.NET MVC? ...

How do I correctly dispose a Linq to SQL DataContext in a Repository?

In a Rob Conery-style ASP.NET MVC application, you typically have a repository: public class CustomerRepository { DataContext dc = new DataContext(); public IQueryable<Customer> AllCustomers() { return db.Customers; } public Customer GetCustomer(int customerID) { return db.Customers.FirstOrDefau...

ASP.NET MVC Model is not populating

Hi All, I am binding Model to the view and its working fine when populating the view but on post back its not sending any data to controllers [AcceptVerbs(HttpVerbs.Post)] public ActionResult InfoNext(MyModel ModelDep) { In the aspx view i am binding properly <%@ Page Title="Information" Language="C#" MasterPage...