asp.net-mvc-2

Ninject giving NullReferenceException

I'm using asp.net MVC 2 and Ninject 2. The setup is very simple. Controller calls service that calls repository. In my controller I use inject to instantiate the service classes with no problem. But the service classes don't instantiate the repositories, giving me NullReferenceException. public class BaseController : Controller { ...

Asynchronous pages in the ASP.NET framework - where are the other threads and how is it reattached?

Sorry for this dumb question on Asynchronous operations. This is how I understand it. IIS has a limited set of worker threads waiting for requests. If one request is a long running operation, it will block that thread. This leads to fewer threads to serve requests. Way to fix this - use asynchronous pages. When a request comes in, the...

ASP. Net MVC and RegisterClientScriptBlock alternative

I currently have a web form aspx page that calls RegisterClientScriptBlock. This sends down message text that I use for client side validation e.g. <script type="text/javascript"> //<![CDATA[ var c_errorMessages = { RequiredField : "* Mandatory field" }; //]]> </script> The values are generated on the s...

Tailspin example keeps failing on ASP.NET MVC2 RC2

I wanted to look at the TailSpin example from PDC2009 but it keeps failing when it does the scan for ASP.NET MVC2 RC2. I'm sure it is installed; Have checked the assembly, System.Web.MVC and it's version 2.0.50129.0. That sould be OK. ASP.NET MVC tools for VS2010 is also installed. Can anyone help me out? How can I overwrite that check? ...

dotnetopenauth with asp.net mvc proving too frustrating to use.

I've been trying excessively hard to implement a good open id solution into asp.net mvc - and everywhere I turn is absolute dead ends. DotNetOpenAuth is just too big and I have been thusfar unable to get even the most simplistic, basic, absolute cut and dry implementation of it to work. NerdDinner had a promising implementation, but it...

Is there a MVC SiteMap Provider that supports ASP.NET MVC 2 Areas feature ?

Hi all, I am looking for a MVC SiteMap provider in which I can specify area as well, along with controller and action. Did anyone use a SiteMap provider that supports MVC 2 Areas ? Help will be greatly appreciated in this regard. Thanks ...

ASP.NET MVC, areas, routing and a controller factory.

Hi, I've an interesting problem with some routing with an ASP.NET MVC app. I'm building a CMS and I've got a catch-all handler that takes the URL and checks to see if there's some matching content in a database. If so, it displays it, otherwise we get a 404. Now I've got all that working with some test data, I moved on to write a quick...

Return ActionResult to a Dialog. ASP.NET MVC

Given a method.. public ActionResult Method() { // program logic if(condition) { // external library // external library returns an ActionResult } return View(viewname); } I cannot control the return type or method of the external library. I want to catch its results and handle that in a dialog on the page - but I...

How does asp.net MVC remember my incorrect values on postback?

This is working, but how??? I have a controller action for a post: [AcceptVerbs(HttpVerbs.Post )] public ActionResult Edit(Person person) { bool isvalid = ModelState.IsValid; etc. The Person object has a property BirthDate, type DateTime. When i enter some invalid data in the form, say 'blabla' which is obvious not a valid Date...

Client-side validation with a model-less view in ASP.NET MVC 2

I'd like to use the new client side validation features in MVC 2 but I have a particular view that just has a couple textboxes on it and I don't want to create a strongly typed model for it. Can someone describe how to leverage the validation goodness in MVC 2 w/o a strongly typed model? ...

How to edit and display Date in ASP.Net MVC 2

I am storing a date in my database and want the user to be able to edit this date in the Edit View. In the past with ASP.Net web forms I have used 3 dropdownlists for the Month, Day and Year to get the date from the user and to bind it on display. I want to do the same in ASP.Net MVC and not sure how to do it? I am not using any jQuery ...

Asp net MVC controllers and widgets

As I understand it, in ASP.NET MVC a httprequest is mapped to a controller/action. As one request is used to get one web page, could we call to these controllers "page controllers"? My other question is about widgets (user controls) and RenderPartial method: If a widget represents a classic ASP.NET webcontrol or usercontrol, and I ...

Why ASP.NET MVC 2 is rendering this code?

I have an bool property in a class. And using <%= Html.EditorForModel() %> its generating this code: <div class="editor-field"> <input class="check-box" id="Ativo" name="Ativo" type="checkbox" value="true"> <input name="Ativo" type="hidden" value="false"> </div> My question is: why it's creating an input hidden ? ...

Is mspec better with or without nunit?

I've seen mspec used with nunit on some blogs and discussions. In fact, most of the examples on the web that I've seen demonstrate mspec with some kind of nunit dependancy or integration. My team is attempting to use mspec without nunit on a new ASP.NET MVC2 project. We're not at the spec-writing stage yet, so I can't tell what is better...

ASP.Net MVC2 (RTM) breaks response filtering - "Filtering is not allowed"

I've just done a test run of upgrading a project to ASP.Net MVC 2 (RTM) in anticipation of the full official .Net 4.0 release coming later this month. Our application is using a minimizer for our CSS and javascript. To do so, it is making use of the HttpResponse.Filter property to set a custom filter. With the upgrade, the setter for ...

ASP.NET MVC 2 RC2 Model Binding with NVARCHAR NOT NULL column

PLEASE NOTE: I've answered my own question with a link to an answer to a similar question. I'll accept that answer once I'm allowed to (unless anyone comes up with a better answer meantime). I have a database column defined as NVARCHAR(1000) NOT NULL DEFAULT(N'') - in other words, a non-nullable text column with a default value of blank...

Setting ModelState values in custom model binder

I am using custom model binder in ASP.NET MVC 2 that looks like this: public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { if (controllerContext == null) { throw new ArgumentNullException("controllerContext"); } if (bindingContext ...

RadioButtonFor in ASP.NET MVC 2

Can someone provide a simple example of how to properly use Html.RadioButtonFor? Let's say it's a simple scenario where my model has a string property named Gender. I want to display two radio buttons: "Male" and "Female". What is the most clean way to implement this while retaining the selected value in an Edit view? ...

Custom IIdentity and passing data from an attribute to a controller

Here's my scenario: I've successfully created a custom IIdentity that I pass to a GenericPrincipal. When I access that IIdentity in my controller I have to cast the IIdentity in order to use the custom properties. example: public ActionResult Test() { MyCustomIdentity identity = (MyCustomIdentity)User.Identity; int userID = ide...

Passing URL parameter and a form data together

I have following URL: http://localhost:49970/Messages/Index/9999 And at view "Index" I have a form and I post the form data to the action Index (decored with [HttpPost]) using Jquery, like this: View: <script type="text/javascript"> function getMessages() { var URL = "Index"; $.post( URL, $...