asp.net-routing

ASP.NET Core Route Change

一笑奈何 提交于 2019-12-08 08:10:33
问题 I need to update a handful of static web pages, and I would like to take this time to recreate them using ASP.NET Core (ASP.NET 5 with MVC 6) in Visual Studio 2015. I want to rebuild it using Microsoft's latest technology to make changes easier in the future. When I start the project on localhost, the default website loads up fine but any of the linked pages break because they route to the /Home controller by default. Also, none of the project's jquery , css or images are found when MVC nests

How do I redirect a route to another route in ASP.NET web forms?

坚强是说给别人听的谎言 提交于 2019-12-07 02:37:18
问题 I have routes like these: routes.MapPageRoute("Survey", "Survey", "~/Survey/Survey.aspx") routes.MapPageRoute("Letters", "About/Letters", "~/Pages/Letters/Letters.aspx") How can I redirect a url like this: /Surveys to the 'Survey' route? So that when the user goes to /surveys it redirects to /Survey. (URLs for the sake of argument) I'd prefer it if I didn't have to place redirect code in the ASPX file itself, and rather just have the code in the route rule, just keeps it simple and

ASP.net WebForms - Using GetRouteUrl in markup

我是研究僧i 提交于 2019-12-06 11:22:53
I have been trying to figure out how to use the Routing features with ASP.net 4.0 WebForms. I added a route to my route collection: void Application_Start() { RegisterRoutes(RouteTable.Routes); } void RegisterRoutes(RouteCollection routes) { routes.MapPageRoute( "about-route", "about/", "~/About.aspx" ); } In my master page I tried to do the following: <asp:HyperLink ID="asdf" runat="server" NavigateUrl='<%= GetRouteUrl("about-route", new {}) %>'>Test</asdf> I got a compiler error: Server tags cannot contain <% ... %> constructs. What is the proper way to create a route URL in a server control

Make ASP.NET MVC Route Id parameter required

被刻印的时光 ゝ 提交于 2019-12-05 21:17:28
I have this route: routes.MapRoute( "PlaceDetails", "{controller}/{action}/{id}", new { controller = "Place", action = "Details", id = UrlParameter.Optional } ); This routes this fine: mysite.com/place/details/123 Making Id 123 available to the details action of the place controller - which can then lookup place '123'. However - this URL is also passed to the controller: mysite.com/place/details/ I want this to return HttpNotFound - but it sends a null Id to the controller - and requires me to handle that. It seems neater if the route itself achieves this rather than needing unseemly null

ASP.NET MVC: Routing hierarchy URL

谁说胖子不能爱 提交于 2019-12-05 15:23:47
How can I make routing for this? URL: /category/main/sub/ or /category/main/sub1/subsub/ I want to have /main/sub/ and /main/sub1/subsub/ as parameters in Index action method of CategoryController. Found the answer: Should use "/category/{*path}" instead of "/category/{path}" in the routing path. 来源: https://stackoverflow.com/questions/1588175/asp-net-mvc-routing-hierarchy-url

How do I redirect a route to another route in ASP.NET web forms?

坚强是说给别人听的谎言 提交于 2019-12-05 07:08:35
I have routes like these: routes.MapPageRoute("Survey", "Survey", "~/Survey/Survey.aspx") routes.MapPageRoute("Letters", "About/Letters", "~/Pages/Letters/Letters.aspx") How can I redirect a url like this: /Surveys to the 'Survey' route? So that when the user goes to /surveys it redirects to /Survey. (URLs for the sake of argument) I'd prefer it if I didn't have to place redirect code in the ASPX file itself, and rather just have the code in the route rule, just keeps it simple and centralized. Thanks Luke You can use something like this Response.RedirectToRoute("Survey"); the parameter

How to create RouteUrls with databound parameters declaratively?

孤人 提交于 2019-12-04 10:03:40
I'm using the new Routing feature in ASP.NET 4 (Web forms, not MVC). Now I have an asp:ListView which is bound to a datasource. One of the properties is a ClientID which I want to use to link from the ListView items to another page. In global.asax I have defined a route: System.Web.Routing.RouteTable.Routes.MapPageRoute("ClientRoute", "MyClientPage/{ClientID}", "~/Client.aspx"); so that for instance http://server/MyClientPage/2 is a valid URL if ClientID=2 exists. In the ListView items I have an asp:HyperLink so that I can create the link: <asp:HyperLink ID="HyperLinkClient" runat="server"

Direct different IP's to different pages on IIS7

走远了吗. 提交于 2019-12-03 17:44:02
问题 Using IIS7, how do I direct internal private network IP's addresses to my web site while I direct external IP addresses to a "site under maintenance" page? So far on IIS7 I've found the section in IIS named "IPv4 Address and Domain Restrictions" and I can add the 3 internal ranges to that as an allow range. That seems easy. Now how do I direct all other traffic to a static page such as app_offline.html that I have created. (I'm not actually going to use app_offline.html because that will

Run two web sites on same port on IIS 7.5?

久未见 提交于 2019-12-03 11:55:42
问题 We need to be able to run two versions of one ASP.net web application on the same intranet server and port number, but with one mapped to / and the other mapped to /experimental (not real names, but close enough). C:\inetpub\wwwroot\Version1 => http://test1.organization.com/ C:\inetpub\wwwroot\Version2 => http://test1.organization.com/experimental The first URL has already been exposed to some beta users and therefore needs to be kept somewhat stable. The second will contain experimental code

Advanced ASP Routing tutorials and examples

谁说胖子不能爱 提交于 2019-12-03 09:38:45
问题 One of major hurdles I seem to be having recently is getting my head around some of the more complex routing requirements for some MVC based applications I've been developing. I'm having problems finding the right set of tutorials to walk me through it to get a complete understanding. What I'd like to find is a complete set of tutorials for everything routing from basic (controller/action/id) to advanced. An example of what I'm calling advanced routing is things like: /blog/year/month/day