asp.net-mvc-2

Why is my ASP.NET Action looking for the wrong View?

为君一笑 提交于 2019-12-13 01:38:03
问题 I have a simple action: public ActionResult CommentError(string error) { return View(error); } I have a simple partial view called CommentError.ascx: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<String>" %> <%: Model %> When I browse to the view directy by going to myurl.com/find/Comments/CommentError the view displays fine... no errors. But, when I go to myurl.com/find/Comments/CommentError?error=SomeErrorString , instead of binding the querystring to string error , it

How to create a Web Setup project in VS 2010 for a MVC2 application?

旧时模样 提交于 2019-12-13 01:15:14
问题 I need help to create a Web Setup project for an MVC2 application I made at home, since I have VS 2010 there and I need to show people at the office, who have VS 2008 + sp1 + MVC2. Thanks 回答1: By adding a web setup project to your solution: 回答2: Create a web setup project; Add project output - select your web project - select primary output - click ok Add project output again - select your web project - select content files - click ok 回答3: Customize it by adding Custom Actions such as IIS

How would I configure the global.config to allow for root path to actionMethod in MVC2?

廉价感情. 提交于 2019-12-13 00:22:46
问题 specifically, the default directory naming structure is [Controller]/[ActionMethod] resulting in a rendered url like www.mysite.com/home/actionMethodName. What if I want to simply imply the Controller (in this example, 'home') so that I can get a url that looks like this: www.mysite.com/actionMethodName. I haven't seen many requests for this kind of configuration. I can see how it breaks convention, but I would imagine that there are lots of people who need root pathing. 回答1: Because you are

Mixing WebForms and MVC: What should I do with the MasterPage?

无人久伴 提交于 2019-12-12 22:18:49
问题 I want to start migrating a WebForms App to MVC. The process will be gradual, so both systems must co-exist. The question is: Should I have two MasterPages, one for the WebForms pages and other for the MVC views? Is there a way to have only one? 回答1: In ASP.NET MVC the master page should derive from System.Web.Mvc.ViewMasterPage while in classic WebForms from System.Web.UI.MasterPage. If in MVC you use the latter you won't have access to any helpers. Although you could use ViewMasterPage in

ASP.NET MVC2 Error: No parameterless constructor defined for this object

﹥>﹥吖頭↗ 提交于 2019-12-12 20:24:14
问题 Edit: This is fixed -- See Solution below Solution : First I incorrectly had my node defined in /shared/web.config instead of the web.config in the root of the WebUI project. I also had not correctly defined my connection string within web.config. I have pasted the proper web.config sections below: <configuration> <configSections> <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor"/> <!--more sectiongroup and sections redacted for brevity

ASP.NET MVC - Simple Breadcrumbs (SiteMap)

依然范特西╮ 提交于 2019-12-12 19:40:55
问题 I have developed a ASP.NET MVC 2 application and I want to put a simple breadcrumbs (sitemap) in each page like this: Home > Movies > Details It is equal the URL: http://localhost/home/movies/details How can I achieve it? I would like to put it in my master page. Thanks! 回答1: If it is always equal to the URL, the absolute simplest thing would be to make use of that by using something like this: var menuitems = Request.Url.AbsolutePath.Split("/".ToCharArray(), StringSplitOptions

Better Way to Build jQuery Tabs

旧街凉风 提交于 2019-12-12 19:22:53
问题 I am utilizing jQuery UI Tabs in an ASP.NET MVC 2 web application. One part of the application requires that I do error checking when I switch away from the tab. I am doing that via this script within the aspx file that contains the tabs. <script type="text/javascript"> $(function () { $("#tabs").tabs({ cache: true, select: function (event, ui) { var $tabs = $('#tabs').tabs(); switch ($tabs.tabs('option', 'selected')) { case 0: $.post("User/Personal", $("#PersonalForm").serialize(), function

How to call static method from ASP.NET MVC controller in C#

与世无争的帅哥 提交于 2019-12-12 18:34:01
问题 GetMethod does not find public static method if called from ASP .NET MVC controller. (From console application it work OK). To solve this dummy SaveEntityGenericWrapper method is used. How to remove SaveEntityGenericWrapper from code ? Why GetMethod("SaveEntityGeneric") returns null but GetMethod("SaveEntityGenericWrapper") works if called from ASP .NET MVC 2 controller ? How to make SaveEntityGeneric private if partial trust is used in MVC2 ? public class EntityBase() { public void

Ninject MVC 2, EF 4, AutoMapper - ObjectContext has been disposed

偶尔善良 提交于 2019-12-12 18:28:29
问题 Completely revised: Okay, I'm using Ninject with the MVC 2 extension as my DI container, and AutoMapper as my entity <--> view model mapper. I'm getting an 'ObjectContext is disposed' error in my view model -> entity mapping. My code is below. Ninject bindings: public class DIModule : NinjectModule { public override void Load() { this.Bind<HGEntities>().ToSelf().InRequestScope(); this.Bind<IArticleRepository>().To<HGArticleRepository>().InRequestScope(); this.Bind<IGameRepository>().To

Cannot debug views in MVC2 project, getting “The resource cannot be found” error

久未见 提交于 2019-12-12 17:25:05
问题 I'm running Visual Studio 2008 sp1 on Win7, with MVC2 RTM installed. I created a new MVC2 project using the wizard and am unable to debug specific pages. With webforms and even MVC1, I was able to sit on a View page, hit F5, and then have the integrated web server in VS2008 start on the page I was working on. Very handy for building up app logic. When I try this now I get a "The resource cannot be found" error page. I retried this just now with a stock new MVC2 Web Application project. Here