asp.net-mvc-2

ASP.NET MVC 2 client-side validation rules not being created

烈酒焚心 提交于 2019-12-21 21:52:52
问题 MVC isn't generating the client-side validation rules for my viewmodel. The HTML just contains this: <script type="text/javascript"> //<![CDATA[ if (!window.mvcClientValidationMetadata) { window.mvcClientValidationMetadata = []; } window.mvcClientValidationMetadata.push({"Fields":[],"FormId":"form0","ReplaceValidationSummary":false}); //]]> </script> Note that Fields[] is empty! My view is strongly-typed and uses the new strongly-typed HTML helpers ( TextBoxFor() , etc). View Model / Domain

ASP.Net MVC & Comet (WebSync)

核能气质少年 提交于 2019-12-21 21:52:51
问题 I'm trying to implement comet in my ASP.Net MVC 2.0 project. I'm using WebSync from FrozenMountain. My website is coded in C# 4.0 and ASP.Net 4.0. The comet code is triggering my MVC controller function with the [HttpPost] attribute (even though the page doesn't refresh or appear to post). Is there a way to determine what is being posted and ignore that route in my global.asax.cs ? Please note, I know how to ignore routes with MVC, that is not the issue. 回答1: The gentlemen at Frozen Mountain

Asp.net - MVC1 vs MVC2

六眼飞鱼酱① 提交于 2019-12-21 19:46:56
问题 can any one precisely explain the difference between ASP.NET MVC1 vs MVC2.. and if i'm having a project in MVC1, how can i migrate it to MVC2 ? 回答1: MVC 2 is a later version of the same library. To upgrade to it, read this page. 回答2: There is a conversion utility, see here: http://weblogs.asp.net/leftslipper/archive/2010/03/10/migrating-asp-net-mvc-1-0-applications-to-asp-net-mvc-2-rtm.aspx 来源: https://stackoverflow.com/questions/2447619/asp-net-mvc1-vs-mvc2

Asp.net - MVC1 vs MVC2

人盡茶涼 提交于 2019-12-21 19:46:25
问题 can any one precisely explain the difference between ASP.NET MVC1 vs MVC2.. and if i'm having a project in MVC1, how can i migrate it to MVC2 ? 回答1: MVC 2 is a later version of the same library. To upgrade to it, read this page. 回答2: There is a conversion utility, see here: http://weblogs.asp.net/leftslipper/archive/2010/03/10/migrating-asp-net-mvc-1-0-applications-to-asp-net-mvc-2-rtm.aspx 来源: https://stackoverflow.com/questions/2447619/asp-net-mvc1-vs-mvc2

How can you inject an asp.net (mvc2) custom membership provider using Ninject?

北城以北 提交于 2019-12-21 18:58:08
问题 OK, so I've been working on this for hours. I've found a couple of posts here, but nothing that actually resolves the problem. So, let me try it again... I have an MVC2 app using Ninject and a custom membership provider. If I try and inject the provider using the ctor, I get an error: 'No parameterless constructor defined for this object.' public class MyMembershipProvider : MembershipProvider { IMyRepository _repository; public MyMembershipProvider(IMyRepository repository) { _repository =

asp.net mvc model inheritance for “simple forms”

坚强是说给别人听的谎言 提交于 2019-12-21 17:56:06
问题 How would you implement this ? I have the following model : class Something { public string Label { get; set; } public DateTime Date1 { get; set; } } class SomethingStage2 : Something { public DateTime Date2 { get; set; } } class SomethingStage3 : SomethingStage2 { public DateTime Date3 { get; set; } } And the following editor templates : EditorTemplates\Something <%@ Control Language="C#" Inherits="ViewUserControl<Something>" %> <%= Html.Hidden( "TypeName", Model.GetType() ) %> <%= Html

PostAuthenticateRequest fires several times

泪湿孤枕 提交于 2019-12-21 12:45:13
问题 I have Forms authentication and I need a custom object to be stored in HttpContext.Current.User and in Thread.CurrentPrincipal. To get this, I listen to PostAuthenticateRequest event, then read from the DB all the user data I need to be stored in HttpContext.Current.User and in Thread.CurrentPrincipal, then I instantiate custom IPrincipal and IIdentity objects and assign them to the above locations. The problem is that for some reason PostAuthenticateRequest fires several times for a single

ASP.NET MVC how to make an action that return a file?

旧街凉风 提交于 2019-12-21 12:43:18
问题 Hello I am generating an excel file inside my action that I would return to the user. How do I have to declare the action to return a file? May I call this action with ajax? thanks! 回答1: Option 1: Use built in ActionResults, such as FilePathResult, FileStreamResult, FileContentResult Option 2: Build a custom ActionResult to return your excel file (example: http://www.dotnetcurry.com/ShowArticle.aspx?ID=484&AspxAutoDetectCookieSupport=1) 来源: https://stackoverflow.com/questions/3935225/asp-net

Asp.net Mvc Display template of String, but now every simple type wants to use it!

风流意气都作罢 提交于 2019-12-21 11:34:33
问题 I created a Display Template which when passed a string renders a disabled text box <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<String>" %> <%: Html.TextBoxFor(model => model, new { disabled = "disabled" })%> Which works great. However, for some reason MVC wants to try and stuff DateTimes and Ints through it as well, which is throwing exceptions The model item passed into the dictionary is of type 'System.Int32', but this dictionary requires a model item of type 'System

xVal and ASP.Net MVC 2 AddModelStateErrors Problem

限于喜欢 提交于 2019-12-21 09:36:46
问题 I have an application that I've been using xVal successfully on for quite some time. It was recently updated to MVC 2. I use the standard DataAnnotations attributes on my domain models, which also implement a "Validate()" method that calls the DataAnnotationsValidationRunner. If there are any errors, that method throws a RulesException. In my controllers, I use the very typical catch for RulesException catch (RulesException e) { e.AddModelStateErrors(ModelState, "err"); } All typical stuff,