asp.net-mvc-3

How to handle service-layer validation in MVC3

I am working on a project which requires different validation sets for the same model, and we're trying to find the best solution to handle it. A simplified example could be using our Customer DTO: public class Customer { [Required] public string FirstName { get; set; } [Required] public string LastName { get; set; } ...

ASP.NET MVC 3 and HTML Helper Extensions

I am trying to work out whether I am misunderstanding something about ASP.NET MVC or whether I have found some sort of bug in ASP.NET MVC Beta 3. I am having a problem with a PartialView picking up the wrong model when using HTML Helper extensions My controller code looks like this: public ActionResult EditGeneral(MapGeneralViewModel v...

Using Razor View Engine within JavaScript

Using the new ASP.NET MVC 3.0 Razor View Engine, is there any way to call upon it within javascript code? In the normal view engine, you could do something like ... <script type="text/javascript"> $(document).ready(function() { function somejQueryFunction(obj) { <%= obj.ExecuteSomething() %> } }); </script>...

ASP.NET MVC 2 Pure jquery client side validation

How do I go about hooking up my validation with jquery only? I do not want to use Microsoft ajax. I saw on this blog exactly what I want, but it seems that the file MicrosoftMvcJqueryValidator.js is deprecated or canceled. Is there an official way to do this now? Possibly using asp.net mvc 3. ...

Does Razor syntax provide a compelling advantage in UI markup?

I notice Scott Guthrie is starting to mention Razor a fair bit on his blog but I'm just not that sure that it's a good fit for my style. Granted it's a fairly unfamiliar style for someone who's pretty used to a "standard" sort of ASP.Net markup (content place holders and inline code), but it just feels like a lot of additional pages to ...

Using Knockout.js with newest jQuery Files and ASP.NET MVC

I am attempting to use Knockout.js with ASP.NET MVC 3.0 (Title gave it away, didn't it?!) http://knockout.js.com I am running into some problems (more related to the new jQuery Tmpl Engine than ASP.NET MVC 3.0). I am using Steve Sanderson's Example Program in my test, and have mostly replicated his results with the new Razor View Engi...

Why am I forced to rebuild my project to see changes made to controllers in ASP.NET MVC?

I'm using ASP.NET MVC 3 Beta and for some strange reason, if I change a controller's action and load the action in a browser, it doesn't recompile the assembly to incorporate the changes made. Maybe I'm spoilt from how things were in ASP.NET Webforms, where there was dynamic on-the-flycompilation of code-behind files, but I think this sh...

ASP.NET MVC 3 beta: TryUpdateModel throws NullreferenceException in unit test

Hi, Since I updated to ASP.NET MVC 3 Beta 1, I get a NullReferenceException whenever I call TryUpdateModel() during a unit test session. The stack trace looks like this: Execute System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.Mvc.JsonValueProviderFactory.GetValueProvider(Con...

Razor Syntax and Javascript...

Hi, As a test I'm converting a proof-of-concept app we've written from Web Forms to Razor, simply so we can evaluate it. I've run into one problem so far that's making my head hurt..generating client-side Javascript... Web-Forms <script type="text/javascript"> var jqGridIdList = "<%: Url.Action ("getidlist", "office", new { area ...

Render partial view with dynamic model in Razor view engine and ASP.NET MVC 3

When I try to render a partial view whose model type is specified as: @model dynamic by using the following code: @{Html.RenderPartial("PartialView", Model.UserProfile);} I get the following exception: 'System.Web.Mvc.HtmlHelper<dynamic>' has no applicable method named 'RenderPartial' but appears to have an extension method by tha...

asp.net mvc utilize view for rendering, without creating a controller action

I need to generate html (for the body of an email message) specific to a Customer object I thought of making a View that gets a Customer object and renders the appropriate text. Is there a way to call a view and get the rendered output without associating it to a controller action? Ideally in pseydocode I would do something like this ...

Learning Materials for ASP.NET MVC 3.0? Please list!

Hello, I am looking for learning materials (like blog posts and tutorials) for ASP.NET MVC 3.0 specific materials. If you know of any books, blogs, sites or online resources that are exclusively, predominently or even mainly MVC 3.0 related, I would love to hear about them, also, specific links to individual MVC 3.0 related tutorials & ...

Get the generic controller type in controllerfactory

I have registered a new route like this context.MapRoute( "Dashboard_default", "Dashboard", new { action = "Index", controller = "Dashboard`1" }, new[] { "SomeNamespace.Controllers" } ); This route makes my CreateController method in my StructureMapControllerFactory to fa...

Tying MembershipUser and Web.Profile together for newly created users

I am using ASP.NET MVC 3. I am using what essentially came with for free in the Visual Studio project template for an MVC project with the "Internet Application" option. Basically this brings in Forms authentication and provides some basic elements to manage user login and stuff. I am also using the web profiles stuff with this to store...

Form submitted twice after updating from ASP MVC 3 Preview to Beta

After upgrading my ASP MVC from 3 Preview to 3 Beta I see strange behaviour in my Ajax forms. @using(Ajax.BeginForm("New", new AjaxOptions() {OnSuccess = "onAjaxSuccess", OnFailure = "onAjaxFailure", OnBegin = "onAjaxBegin", HttpMethod = "Post"})) {} <form action="/Order/New" data-ajax="true" data-ajax-begin="onAjaxBegin" data-ajax-fai...

How (and when) do I use TFS with private DLLs that can also be served by NuGet/NuPack?

We have a couple of private "Enterprise Services" DLLS that are used in all our Websites for authentication, logging, etc. Since they are private, we also control the versioning and source of these DLLs. Our historic (error prone) steps after creating File | New Project include Add the "Enterprise Services" project Add a reference t...

How can I use Razor in non-web applications... such as a mail merge program?

Has anyone attempted to use Razor outside of a Web Application, such as within a C# commandline application? Generally how would one go about using Razor to do a simple mail merge? It seems to be possible based on the comments of this blog post. ...

using an asp.net IHttpModule to read data sent after headers without content-length...

Hi, I'm writing an application within asp.net MVC 3 Beta. The application will receive an HTTP GET request with various headers. After this request the client sends 8 bytes of data. The client does NOT set a Content-Length header so as far as I can tell asp.net ignores the data that follows the headers. I need this data! My Request...