asp.net-mvc-2

How to use Routing in MVC for SEO Friendly URL

百般思念 提交于 2019-12-08 01:24:01
问题 Generally we have following sample code in our global.asax file. So, my question is how we can have multiple MapRoute and how to use them ??? I want URL like: http://domain/Home.aspx/Index/Cricket-Ball/12 public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } I want something like this, but i don't

MVC contrib pager

十年热恋 提交于 2019-12-07 23:03:49
问题 I am using it like this: <%= Html.Pager((IPagination)Model) %> Is there are simple way to change the rendered url. I had a look for more documentation but couldn't find much. 回答1: What exactly do you want to change? This is how I change the URL: Html.Pager(Model.AssetsPagedList) .First("First") .Last("Last") .Next("Next") .Previous("Previous") .Link(currentPage => Url.Action("Browse", new { page = currentPage, searchTerm = Model.SearchModel.SearchTerm, excludedWords = Model.SearchModel

ASP.Net MVC 2.0: EditorFor setting name via attributes

三世轮回 提交于 2019-12-07 22:58:35
问题 Just wondering how do I mimic the following using attributes... <%= Html.EditorFor(x => x.SportProgramIdList, "FormMultiSelectDropDownList", "SportProgramIds")%> I know I can specify the template by using [UIHint("FormMultiSelectDropDownList")] but I am left with the problem with how to set the name... Cheers Anthony 回答1: I Guess you'll have to create your own CustomAttribute UINameAttribute . You could use the ModelMetadata to keep your attribute and then I'm not sure what would be the best

Resource file for MVCSiteMapProvider

断了今生、忘了曾经 提交于 2019-12-07 19:16:18
问题 I'm using MVCSiteMapProvider for generating menus with localization for my application. My program works fine as long as the resource files for the menus are in the App_GlobalResources folder. When I move the resources into another folder, it gives an error mentioning not able to find the resources. I'm using $resources:Resource,menu_Home for accessing the resources in the MVC.sitemap file. I want to keep the resource files in a custom folder without storing them in the App_GlobalResources

Asp.net mvc RenderAction RouteData Controller and Action values

不羁的心 提交于 2019-12-07 17:20:37
问题 I am trying to create a RenderAction method on the Master page that will dynamically generate a side bar based on the current controller and action. When the RenderAction is called in the view it is populated with the controller and action of that particular RenderAction Method. For Example, if I am on the controller of “Home” and action of “Index” I am expecting "Home" and "Index" in the GenerateSideBar method. Instead I get the controller of “Home” and action of “RenderSideBar”. Thanks For

ASP.NET MVC 2 strongly typed htmlhelper, indexes

巧了我就是萌 提交于 2019-12-07 17:12:25
问题 public class Foo { public bool Checked {get;set;}} View: <viewdata model="Foo[] fooList" /> <for each="var f in fooList"> ${Html.CheckBoxFor(x=>x[fIndex].Checked)} </for> Will output: <input id="Checked" name="Checked" type="checkbox" value="true" /> <input name="Checked" type="hidden" value="false" /> <input id="Checked" name="Checked" type="checkbox" value="true" /> <input name="Checked" type="hidden" value="false" /> <input id="Checked" name="Checked" type="checkbox" value="true" /> <input

Not able to access GetModelStateValue in custom control in asp.net mvc2

戏子无情 提交于 2019-12-07 16:59:11
问题 I am trying to write a custom control for text box control where in would like to generate the control based on some input attributes , I am not able to access GetModelStateValue in my custom control. How do i do this ? 回答1: You won't be able to access it as that method is marked as an internal method. The best you can do is just duplicate the MVC source code and place that method somewhere where you can access it. You can use the following. Note you will need to pass in the htmlHelper object

asp.net request.form

本小妞迷上赌 提交于 2019-12-07 15:48:33
问题 public ActionResult DisplayCustomer() { Customer objCustomer = new Customer(); objCustomer.Id = Convert.ToInt16(Request.Form["Customerid"]); objCustomer.CustomerCode = Request.Form["code"]; objCustomer.Amount = Convert.ToDouble(Request.Form["amount"]); return View(objCustomer); } This is my action in controller(MVC 2 aspx): <form action="DisplayCustomer" method="post"> Customer id:- <input type="text" id="Customerid" /><br /> Customer Code:- <input type="text" id="code" /><br /> Customer

ASPNETDB.MDF file not showing up in APP_DATA

本秂侑毒 提交于 2019-12-07 15:42:38
问题 I'm taking Microsoft's walk through on MVC 2 Forms Authentication - http://msdn.microsoft.com/en-us/library/ff398049.aspx According to the walk through, when I register a user, ASP.NET creates the ASPNETDB.MDF file and it is supposed to show up in my APP_DATA folder upon refreshing in the solution explorer. The problem is, for me it is not and I want to have a look inside so I can understand it's structure. I can continue to run the project and login as the user I created, yet the ASPNETDB

Can we deploy MVC 4 application on IIS 6

杀马特。学长 韩版系。学妹 提交于 2019-12-07 14:45:45
问题 I have got a new task to convert mvc 2.0 application into mvc 4.0 using razor engine. Currently MVC 2.0 applicaion is hosted on Window Server 2003 and IIS 6. My question is, Can we use the same enviroment for mvc 4.0 application or should we need to upgrade the IIS? 回答1: You can follow these steps Open IIS Manager, expand the master server node (i.e, the Servername node), and then select the Web service extensions node. In the right pane of IIS Manager, right-click the extension "ASP.NET v4.0