asp.net-mvc-2

Ninject error: he IControllerFactory 'Ninject.Web.Mvc.NinjectControllerFactory' did not return a controller for the name 'Products'

僤鯓⒐⒋嵵緔 提交于 2019-12-24 04:02:11
问题 I'm Getting the following yellow screen of death "The IControllerFactory 'Ninject.Web.Mvc.NinjectControllerFactory' did not return a controller for the name 'Products'." Why? Here's my setup Update This configuration works on my computer but not on my co-worker's computer even though our computers have the same code and configuration. Code public class MvcApplication : NinjectHttpApplication { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{

Can't set up asp.net mvc 2 RC and spark view engine

断了今生、忘了曾经 提交于 2019-12-24 03:05:41
问题 Does omebody has ideas how to fix "Method not found: 'Void System.Web.Mvc.ViewContext..ctor(System.Web.Mvc.ControllerContext, System.Web.Mvc.IView, System.Web.Mvc.ViewDataDictionary, System.Web.Mvc.TempDataDictionary)'." exception. This solution doesn't work http://dotnetslackers.com/articles/aspnet/installing-the-spark-view-engine-into-asp-net-mvc-2-preview-2.aspx. Thans for all. 回答1: I had to download the spark view engine source code (http://sparkviewengine.codeplex.com/Release

ASP.NET MVC ActionResult View() not changing url

大城市里の小女人 提交于 2019-12-24 02:44:16
问题 I have a method... [HttpPost] public ActionResult Start(SomeViewModel someViewModel) { ... } that based on some conditions returns things like return View("Invalid") , View("NotFound") , View("Run", anotherViewModel) , etc. The problem is that no matter what view I present, the URL does not change to reflect the new controller/action. This poses a problem when my View wants to post to a different action. How can I fix this? 回答1: The View(...) methods don't redirect, they simply render out the

Receive JSON from external server, parse it and save it to local database with MVC2

点点圈 提交于 2019-12-24 02:36:08
问题 I need to build a MVC2 project that can receive JSON ({"Address":"Streetname","Age":42"}) which is sent from an external server, parse it and save it to my local database (maybe with the help of a model?). As I have never done this before, I am unsure about how to handle it. I would need some pointers about which technique it is recommended in this case (Linq to sql, Entity Framework, ADO.NET Entity Framework) and how to receive the JSON string (ActionMethod, or maybe in the Controller?) and

Can we deploy an asp.net MVC application by copying the source codes (without compiling) like we can do when deploying a WebForm website proj?

给你一囗甜甜゛ 提交于 2019-12-24 01:47:09
问题 Can we deploy an asp.net MVC application by copying the source codes only (without compiling them first) like we can do when deploying WebForm website project? 回答1: No - MVC apps need compilation, like ASP.NET Web Application Projects. 回答2: Wait... if what you mean is copying the *.aspx and *.ascx files, yes you can, but you have to include the *.dll in the bin folder too. Copying the *.cs files is useless. Start by building your application, then select the project (not the solution) that is

MVC: Generating an AntiForgeryToken for a AJAX response to the client

ぐ巨炮叔叔 提交于 2019-12-24 01:37:57
问题 I've spent a good few hours tonight trying to work this one out. Basically I have a form in MVC with an AntiForgeryToken so when I post back everything is validated and it's all good. The problem is that I have a JSON result method that generates a load of markup and returns HTML to the user. I am regenerating forms to return to the user in an ajax way, so I need to put the token into the HTML I return to the client otherwise when they POST back again the antiforgery stuff will still work. So

ASP.NET MVC 2 Model Errors with Custom Exceptions

*爱你&永不变心* 提交于 2019-12-24 00:34:22
问题 I have a custom exception class: public class MyException: Exception { public MyException(MyExceptionEnum myError) : base(myError.ToDescription()) { } public MyException(MyExceptionEnum myError, Exception innerException) : base(myError.ToDescription(), innerException) { } } .ToDescription is a extension method on MyExceptionEnum to provide enum-to-string mapping for the exception error details. Here's how i throw it: if (someCondition) throw new MyException(MyExceptionEnum.SomeError); So i

How do I use DisplayFor() for objects that are not directly part of my model in asp .net mvc 2?

荒凉一梦 提交于 2019-12-24 00:14:45
问题 I'm sure I'm missing something pretty simple here. I've created a custom DateTime display template. This works fine when using: <%= Html.DisplayFor(x=>x.DateTimeProperty) %> However, I have a situation where I am iterating over objects in the Model in a for loop while inside a partial control. I want a DateTime property to use the display template, but I can't figure out how to instruct it to do so. The property is a DateTime as it should be. The looks like: <% foreach (var item in Model) { %

Passing data from the model into custom validation class

江枫思渺然 提交于 2019-12-23 21:26:33
问题 I have a data validation class that checks whether the start date of a meeting is before the end date. The model automatically passes in the date that requires validation, but i'm having a bit of difficulty passing the data that it needs to be validated against. Here's my validation class sealed public class StartLessThanEndAttribute : ValidationAttribute { public DateTime DateEnd { get; set; } public override bool IsValid(object value) { DateTime end = DateEnd; DateTime date = (DateTime

Can't disable jQuery cache

流过昼夜 提交于 2019-12-23 20:46:09
问题 Update I figured out that it must be caching problem but I can't turn cache off. Here is my changed script: <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script type="text/javascript"> jQuery.ajaxSetup({ // Disable caching of AJAX responses cache: false }); jQuery("#button1").click(function (e) { window.setInterval(refreshResult, 3000); }); function refreshResult() { jQuery("#divResult").load("/Home/Refresh"); } </script> It updates part of a web page every 3