asp.net-mvc-2

Asp.Net MVC 2 Client validation implementation for Enterprise Library Validation Block

拜拜、爱过 提交于 2019-12-22 17:46:07
问题 I've found a very good article about how to use EntLib Validation Block for server validation in MVC 2. But as there pointed out The current design of EntLib’s Validation Application Block uses the Composite pattern; that is, when we ask for validation for an object, it returns back a single validator object that contains a list of all the validation work to be done. While this is very convenient from a normal usage scenario, the unfortunate side-effect is that we can’t “peek inside” to see

MVC ListBoxFor raises “value cannot be null” exception

有些话、适合烂在心里 提交于 2019-12-22 15:37:52
问题 I am trying to use the Html.ListBoxFor helper to show a list box and return the selected Id. Is there a problem with the dataValueField not being a string? If the SelectList contained in the model uses integers as the dataValueField then I get a "Value cannot be null - Parameter name: Source" exception raised when the list is rendered in the view. If the Id is changed to a string then everything works and the selected Id is passed back to the view. Any ideas? Here is the controller (based on

Silverlight, RIA Services, MVC2P2 = No Data

南笙酒味 提交于 2019-12-22 13:13:13
问题 I am having trouble upgrading my current project to use RIA Services. I added all the necessary web.config changes but still no luck. I everything compiles fine but when I hit the page using the datacontext I get an error. I debugged with fiddler and I'm getting a 404 on one of the request. I am getting back headers in my grid so some communication is happening but no data is actually coming through. Another thing to note is that my MVC is running windows authentication. I do have a

Fixture.CreateAnonymous method kills test runner process with an error (AutoFixture) when using AutoMoq to create a Controller

偶尔善良 提交于 2019-12-22 13:08:10
问题 I'm trying to use the AutoMoqCustomization with AutoFixture to create an ASP.NET MVC2 Controller in a unit test via the Fixture.CreateAnonymous method. I've tried in both xUnit under TestDriven.NET, the xUnit test GUI and in MSTest and all have the same result: a massive failure of the process running the test. On Windows 7 x64 if that matters. To reproduce, simply create a new ASP.NET MVC2 project, add the references to AutoFixture, AutoMoq and Moq (3.1, as per the AutoMoq source) and try

ASP.NET MVC ModelState.IsValid doesnt work

感情迁移 提交于 2019-12-22 12:54:58
问题 I've this controller's method for create [HttpPost] public ActionResult Create(Topic topic) { if (ModelState.IsValid) { topicRepo.Add(topic); topicRepo.Save(); return RedirectToAction("Details", new { id = topic.ID }); } return View(topic); } and this for edit [HttpPost] public ActionResult Edit(int id, FormCollection formCollection) { Topic topic = topicRepo.getTopic(id); if (ModelState.IsValid) { UpdateModel<Topic>(topic); topicRepo.Save(); return RedirectToAction("Details", new { id =

Returning http status code 409 Conflict (without ASP.NET MVC alterations)

浪子不回头ぞ 提交于 2019-12-22 12:23:13
问题 I am trying to return a HTTP response with 409 status code, content type "application/json" and a json data in the content. The problem is that at the client level, response.content returns html result. Somehow ASP.Net MVC has decided to return a html error message instead of what I intended. I've checked at web.config and 409 is not part of the custom error message. I've checked IIS 7.0 Error Pages section as well for 409 and it is not set there. I wonder where I can find the default

Change default “The {0} field is required” (ultimate solution?)

时光怂恿深爱的人放手 提交于 2019-12-22 11:35:32
问题 Good day! I've the following ViewModel class I use for login form: using System.ComponentModel.DataAnnotations; ... public class UserLogin : IDataErrorInfo { [Required] [DisplayName("Login")] public string Login { get; set; } [Required] [DisplayName("Password")] public string Password { get; set; } [DisplayName("Remember Me")] public bool RememberMe { get; set; } #region IDataErrorInfo Members // This will be a Model-level error public string Error { get { if (!WebUser.CanLogin(Login,

ASP.NET Mvc - nullable parameters and comma as separator

老子叫甜甜 提交于 2019-12-22 11:25:55
问题 How should I define route in my global.asax to be able use nullable parameters and coma as separator? I'm trying to implement routing rule for my search users page like "{Controller}/{Action},{name},{page},{status}" Full entry from the Global.asax: routes.MapRoute( "Search", "{controller}/{action},{name},{page},{status}", new { controller = "User", action = "Find", name = UrlParameter.Optional, page = UrlParameter.Optional, status = UrlParameter.Optional } ); Routine defined like above works

log4net RollingFileAppender and IIS 7.5

為{幸葍}努か 提交于 2019-12-22 11:22:46
问题 I'm trying to use log4net with a RollingFileAppender on IIS 7.5 / Server 2008 R2. However, the configuration from my old IIS 6 / Server 2003 box doesn't appear to work anymore, I simply don't see any log files being created, here's what I've got setup: In Web.config (inside <configSections> ) <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> In the same file (inside <configuration> ) <log4net> <appender name="ConsoleAppender" type="log4net.Appender

log4net RollingFileAppender and IIS 7.5

你离开我真会死。 提交于 2019-12-22 11:21:23
问题 I'm trying to use log4net with a RollingFileAppender on IIS 7.5 / Server 2008 R2. However, the configuration from my old IIS 6 / Server 2003 box doesn't appear to work anymore, I simply don't see any log files being created, here's what I've got setup: In Web.config (inside <configSections> ) <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> In the same file (inside <configuration> ) <log4net> <appender name="ConsoleAppender" type="log4net.Appender