asp.net-mvc

What approach does asp.net mvc supports?

Hai guys, I know asp.net web forms supports event driven programming approach and it has 'n' number of events. Now my question is What approach does asp.net mvc supports? ...

ASP.NET MVC: How dumb should my view be?

Ok, I'm not talking about making business logic decisions, but rather UI decisions. For example, I'm rendering a table and one column displays a DateTime? property that needs to be formatted. Because the value is nullable I need to check that it's not null before formatting. If I wanted to be pedantic, I would have a FormattedDate prop...

Generating an action URL in JavaScript for ASP.NET MVC

I'm trying to redirect to another page by calling an action in controller with a specific parameter. I'm trying to use this line: window.open('<%= Url.Action("Report", "Survey", new { id = ' + selectedRow + ' } ) %>'); But I couldn't make it work; it gives the following error: CS1012: Too many characters in character literal. C...

ASP.NET MVC OutputCacheAttribute: do not cache if a parameter is set?

I have the following action: public class HomeController : Controller { public ActionResult Index(int? id) { /* ... */ } } I'd like to [OutputCache] that action, but I'd like that either: it doesn't use the cache if id == null; or it uses the cache if id == null but with a different duration. I think I can achieve this by: pu...

Response.ContentType sporaticly changes for IE8 using ASP.NET MVC

We are running ASP.NET MVC on IIS6. We have started to notice a problem with IE8 clients. Almost all the time, the ContentType returned is 'text/html' but occasionally, it will be returned as 'application/xhtml+xml'. This is causing IE8 to try and download the file instead of rendering the contents in the browsers. I can't find any re...

It is possible to use WCF + DTO's + Automapper?

I want to use automapper with a structure that uses WCF + DTO's but I want to know how the question of the eager loading with entity framework 4.0 work with the mappings of the automap. ...

A random call for a style.css action, which doesn't exist - Why?

My error logger has logged an error recently that just boggles me. Here's a copy'n paste of the error: A public action method 'style.css' could not be found on controller 'ProductController'. So I ran a search over the entire solution for references to style.css. There are none, and I have no stylesheet named style.css. The c...

MvcApplication.Error Not Firing (global.asax)

Hi The MvcApplication.Error event in my MVC application will not fire. I have the following in web.config: <system.web> <customErrors mode="Off" /> ... And the following event defined in global.asax: Public Sub MvcApplication_Error(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Error Dim lastErrorWrapp...

Will exceptions in a View be caught by the Controller OnException(), or how do I catch them?

I am in the process of making sure our MVC app catches all exceptions and reports them to us so we can stay on top of the errors. I already learned that I need some code in the Global.asax Application_Error event to catch exceptions that never make it to the Controller, and that in our custom base Controller we override the OnException()...

Limit/Count Characters in CKEditor w/ Jquery

I am using CKEditor for my wysiwyg editor and I need to monitor and limit the character count as they are typing I have a jquery script that works fine for a normal TextArea <script type ="text/javascript" language="javascript"> function limitChars(textid, limit, infodiv) { var text = $('.' + textid).val(); var textl...

MVC - FilePathResult Not working in IIS6

Hi, in my project I have a few actions for specifically returning files (pdf/excel) within my view using FilePathResult. Unfortunately my hosting is currently in IIS6 and while the routing is working by using wildcard mapping for aspnet_isapi.dll the file links simply arent. Is there any way to get these to work with IIS6 ...

How to set the default debug page in MVC 2?

In MVC 1 in VS2008, you could right click the Default.aspx page and set as default page, then hit debug and land on the home view (even though Default.aspx was something else). In MVC2, Default.aspx isn't there, so how do you set the default document to be the home index default view? I know it is set this way by default, but if you ar...

How should I store my ASP.NET MVC site's settings?

I have an ASP.NET MVC site which is composed of 3 projects in a solution: DomainModel (Class Library - Holds LINQ Repo) DomainServices (Class Library - Holds Business Logic) WebUI (ASP.NET MVC Site) I need a place to store a bunch of settings for our site that can be configured via XML. Which project should this go in? ...

MVCContrib ActionFilter PassParametersDuringRedirect still passes reference type in querystring

I am attempting to use the PRG pattern in an asp.net mvc 2 rc application. I found that the MVCContrib project has a custom action filter that will auto persist the parameters in TempData In an action I have the following return this.RedirectToAction(c => c.Requested(accountAnalysis)); however this is adding a querystring param to...

How can I make www.mywebapp.com/bin return a 404 in ASP.NET MVC?

I'm using ASP.NET MVC to develop a web application, deploying to IIS 7. I've hidden my Files and Views directories with web.config files in those directories (they just return a normal 404). However, I haven't been able to get the web.config method to work in hiding my bin directory. When I access www.mywebapp.com/bin, I instead get a...

ELMAH.axd is browsable but will never log any of my errors?

I have it all set up and I can browse to /elmah.axd but I have been causing all these errors and it won't log any of them, it just says 'no errors logged'... what the heck did I do wrong? Here is the stuff I have added to my web.config: <configSections> <sectionGroup name="elmah"> <section name="security" requirePermissi...

ASP.NET MVC and Response.Write in a master page

I have this code in my ASP.NET MVC project master page: <% switch(Request.Browser.Browser) { case "IE": // Internet Explorer Response.Write("<link href=\"./Content/Site_IE.css\" rel=\"stylesheet\" type=\"text/css\" />"); break; case "AppleMAC-Safari": // Chrome Response.Wr...

Dynamically-generated .wav file in ASP.net is all messed up

So I've got this chunk of code in an ASP.net MCV2 View, which is making a computer dude read some data. I'm doing this to integrate with an IVR system, and I want the IVR to be able to pretend the .wav file is a remote resource, like: http://servername/Account/12345/Balance.wav SpVoice speech = new SpVoice(); SpeechStreamFileMode SpFi...

xVal Date Validation with Nhibernate Validator

I am using xVal with NHibernate Validator and I have a hard time to validate the dates. First, NHibernate does not have validation for Date/DateTime formatting (except Past and Future). Second, I tried xVal itself (not using NHibernate Validator) but still no chance. I need to validate the date values (let's say in a text box), to mak...

how to change appliocation URL in IIS

Hi All, My web application URL is http://Domain.com/ParentVirtualDirName/ChildVirtualDirName/Controller/View this is how i have configured in my local IIS. Now when it goes for Quality Assurance the Url is http://Domain.com/ChildVirtualDirName/Controller/View They don't have Parent Vritual Directory name. This causing relat...