asp.net-mvc

How can I differentiate between smart phones and others?

Hi all, I'm looking to revamp our mobile site with something simple for phones below the ambiguous smart phone category and something a little more interesting for the phones above this category. I'm not interested in WAP/WML for this project. I'm building a ASP.Net 4 MCV 2 app and using MBDF What I'd like to know is how best to define...

Support for nested model and class validation with ASP.NET MVC 2.0

I'm trying to validate a model containing other objects with validation rules using the System.ComponentModel.DataAnnotations attributes was hoping the default MVC implementation would suffice: var obj = js.Deserialize(json, objectInfo.ObjectType); if(!TryValidateModel(obj)) { // Handle failed model validation. } The object is com...

Issue using JSON with JQuery and MVC

I'm trying to execute my controller from javascript using jquery... here is my jquery code that is executing.. <script type="text/javascript"> $('form').submit(function (e) { e.preventDefault(); $.ajax({ type: "POST", url: $(this).attr("action"), data: $(this).serialize(), contentType: "application/json;charset=utf-8", ...

ASP.NET MVC download image rather than display in browser

Rather than displaying a PNG in the browser window, I'd like the action result to trigger the file download dialogue box (you know the open, save as, etc). I can get this to work with the code below using an unknown content type, but the user then has to type in .png at the end of the file name. How can I accomplish this behavior witho...

How can I handle maxRequestLength exceptions elegantly?

In my ASP.NET MVC (v2 if it matters) app, I have a page that allows the user to upload a file. I've configured the maxRequestLength for my app to allow files up to 25MB. As a test, I send it a 500MB file which throws the exception: Maximum request length exceeded. (I only know this because ELMAH catches the error and logs it.) In my w...

Server.Execute - render .ASP from MVC controller action

I need to render an ASP page to a string from an MVC controller action. I can use Server.Execute() to render a .aspx page, but not a .asp page. Here's what I'm using: public ActionResult Index() { Server.Execute("/default.asp"); return new EmptyResult(); } which returns `No http handler was found for re...

How to force asp.net MVC 2 to redirect to default controller/action

In a brand new ASP.NET MVC2 project, I want the user to be redirected to http://&lt;mysite&gt;/home/index rather than http://&lt;mysite&gt;/ We do this with our other sites for tracking purposes, to avoid the scenario where hits to the same default page show up as http://&lt;mysite&gt;/ http://&lt;mysite&gt;/default.aspx How...

asp mvc custom HTTP 401 page

I'm trying to get a custom HTTP 401 error working on asp mvc 2 on the development server with no luck. In my root web.config i have <authentication mode="Windows"> </authentication> and <customErrors mode="On"> <error statusCode="401" redirect="/Home/NotAuthorized"/> </customErrors> and i've defined the Action on the Home co...

IIS removing headers on unhandled Exceptions?

I'm playing with ASP.NET MVC a bit and have written a filter to compress my output (OnActionExecuting). Everything works fine except when the controller throws (and doesn't handle) an exception. The problem I'm having is that the content seems to still be compressed, but the browser never gets the content-encoding header. I've checked...

How do I make this ASP.NET MVC controller more testable?

I have a controller that overrides OnActionExecuting and does something like this: protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); string tenantDomain = filterContext.RouteData.Values["tenantDomain"] as string; if (!string.IsNullOrWhiteSpace(tenantDomai...

ASP.NET MVC2 and AJAX

I am currently developing a new website utilizing ASP.NET MVC2. Much of what I want to do with the website (from a front-end standpoint) involves AJAX-y-type tasks. Two examples: I want to display forms, and switch between them via a drop-down menu (or through links) without having to go back and hit the server every single time. I wa...

How to write an "OR" within a Linq to Sql .Where()

I want to get all records WHERE (s.override == 1 OR (s.override == 2 AND s.approved == 1)) How can I do that using the .Where x.subcontracts.Where(s ==> ??) ...

How to determine the current version of ASP.NET MVC?

Is there a way to get the current version of ASP.NET MVC in code? Reflecting on MVC assemblies is needed? Any new IIS server variables? Some property to read in HTTP context? ...

Why does this render as a list of "System.Web.Mvc.SelectListItem"s?

I'm trying to populate a DropDownList with values pulled from a property, and my end result right now is a list of nothing but "System.Web.Mvc.SelectListItem"s. I'm sure there's some minor step I'm omitting here, but for the life of me I can't figure out what it is. The property GET generating the list: public IEnumerable<SelectListIt...

Configuring ASP.NET MVC ActionLink format with GoDaddy shared hosting

Background I have a GoDaddy shared Windows hosting plan and I'm running into a small issue with multiple domains. Many people have previously reported such an issue, but I am not interested in trying to resolve that problem altogether; all I want to accomplish is to change the format of my ActionLinks. Issue Let's say the domain th...

How to remove the link if value is 0 using asp.net mvc

awesome worked fine for me.. due to security I am editing my code.. thanks ...

DavCInt User Agent and Options Verb Requests

We are getting quite a few errors in our logs where the user agent is DavCInt and verb is OPTIONS. Does anyone know who/what might be making this type of request? We are using ASP.NET MVC and all of our controller actions are decorated with HttpGet or HttpPost as appropriate so a controller supporting the request is of course not found...

Automatic User Authentication Framework for Controllers in ASP.NET MVC?

In rails I could do something like this to make sure a user is authenticated before accessing an action in the controller: before_filter :checked_logged_in, :only => [:edit, :update] I was wondering if ASP.NET MVC had something similar or if there was a framework out there that could essentially do something like the following: For c...

Which JavaScript or ASP.NET Charting Component/Tool/Library Will Work For This?

[Update]: Forgot to include ComponentArt... Hi, An interaction designer employed by the client I am currently working for produced some mock-ups, and now it is my job to determine the best way of implementing the charts included therein. After looking at the options I am aware of and was able to find doing some simple Google searches,...

Nerddinner inserting longitude and latitude to database MVC

i am facing a problem in the nerddinner, what i am facing: in the DinnerForm.ascx there is a javascript code $(document).ready(function () { NerdDinner.EnableMapMouseClickCallback(); $("#Dinner_Address").blur(function (evt) { //If it's time to look for an address, // clear out the Lat and Lon ...