Web Forms :: How To Use Same Number Of Parameters For Two Pages In URL Routing

May 7, 2015

I have some routes defined in global.asax according to which the page is redirected.

 Global.asax
void Application_Start(object sender, EventArgs e) {
RegisterRoute(System.Web.Routing.RouteTable.Routes);
} void RegisterRoute(RouteCollection routes) {
routes.MapPageRoute("MainCategory", "{state}/{mcat}", "~/MainCategory.aspx");
routes.MapPageRoute("carriers", "{state}/{mcat}/{dcat}", "~/carriers.aspx");
routes.MapPageRoute("carrierdevices", "{state}/{mcat}/{dcat}/{carrier}", "~/carrieritems.aspx");
routes.MapPageRoute("cellphone", "{state}/{mcat}/{dcat}/{carrier}/{device}/{id}", "~/Catalog.aspx");
//New Rout with same parameters
routes.MapPageRoute("iphones", "{state}/{mcat}/{dcat}", "~/iphones.aspx");
}

i mean to say how to decide the destination page depending on URL Eg:1.routes.MapPageRoute("carriers", "{state}/{mcat}/{dcat}", "~/carriers.aspx"); 2.routes.MapPageRoute("iphones", "{state}/{mcat}/{dcat}", "~/iphones.aspx");

if value in URL second parameter i.e mcat=cellphone then it must redirect to carriers.aspx. and if mcat=iphone then it must redirect to iphones.aspx page.

Problem:currently if in URL there are 3 parameters then it always goes to carriers.aspx as it searches in route table for 3 parameters it redirects to carriers.aspx which need to be conditionally redirected depending on mcat valuehow to do?

View 1 Replies


Similar Messages:

Web Forms :: Pass Multiple Parameters In URL Routing

May 7, 2015

I have seen demo on remove .aspx extension from url in asp.net, its a great articale, but i have few queries which i would like to ask.

How we can use same approcah when we are passing multiple values in a query string like:

"www.localhost/Category.aspx?Id=1&Name=abc"

In example shown that we need to write below code in global file like :

 routes.MapPageRoute("CustomerDetails", "Customers/{CustomerId}", "~/CustomerDetails.aspx");

but what about in above case?

View 1 Replies

MVC 2 Bug In Routing And Parameters?

Jul 12, 2010

I consider the following an error, and not a feature:

When posting a request, any parameters are held in the HttpContext.Request.Form as key/value pairs. This is perfectly fine for the recipient of the request. Unfortunately, however, further down the chain these values still exist and take precedent in binding over new parameters created during processing.

This is obvious in the RenderAction scenario. If a new parameter is created in a view and passed through RenderAction, if the parameter has the same name as one of the initial request parameters (or a form field for that matter), then MVC Binding will bind the initial request form value to the Action being called, and not the new parameter being defined in the RenderAction call. What's even more frustrating, is there is no easy way to override the initial form values.

It really does not make sense that a value defined in one context, should live throughout the entire processing context... at least without the developer being able to determine it should remain. At a minimum, any new parameter defined in the process with the same name should either a) be received as a parameter and not a form value; or b) override the form value.

View 5 Replies

MVC :: Routing - How To Get URL Parameters With Regex

May 27, 2010

I would like to be able to type in a URL like [URL] arrive at a Details Page which parsed the "M" and the "123" from the query string and used them as params to query a Table in my Database. I've been reading my @$$ off and I can't find anything close :>

View 3 Replies

Routing With Parameters In .NET Application?

Oct 7, 2010

I need to use routing with parameters in my ASP.NET application.

public class Global : System.Web.HttpApplication
{
void Application_Start(object sender, EventArgs e)

Then, by navigating to "/Profile" I want to get on Page_Load method Request.Params["Id"] as null and by navigating to "/Profile/1", Request.Params["Id"] as "1".

View 1 Replies

4.0 URL Routing With Two Or Multiple Querystring Parameters

Aug 16, 2010

How can I pass two querysting parameters in URL routing using ASP.NET 4.0? I have gone through many articles, but everywhere it shows only one parameter. I'd like the display URL to be: [URL] The first parameter is ID: 1 The second is Name: This is my first report I am trying following route, but it is not working

routes.MapPageRoute(
"MarketReports", // Route name
"Reports/{*i}-{*n}", // Route URL
"~/pageControl2.aspx" // Web page to handle route
);

How can I make this work as described?

View 1 Replies

.net MVC Routing To Controller With Optional Parameters

Apr 9, 2010

I have a controller method that is called with many different combinations of URL's. To overcome issue i am using optional parameters.here is my controller method signature...public ActionResult localMembersSearch(string Gender, string calling, [Optional]string Region, [Optional]string County, [Optional]string Town, [Optional]string queryvalues)the first two parameters are not optional but always expect

View 1 Replies

.net Webforms Routing Optional Parameters

Sep 23, 2010

I want to add optional parameters in my routing table.For example I would like the users to browse a product catalog like this:http://www.domain.com/browse/by-category/electronics/1,2,3 etc

routes.MapPageRoute(
"ProductsBrowse",
"browse/{BrowseBy}/{Category}",
"~/Pages/Products/Browse.aspx"

View 1 Replies

Handle Optional Parameters In URL Routing?

Jun 2, 2010

I've already implemented URL routing in my app but there are cases where I may or may not get a paramter. In particular, I'm trying to come up with a good way to handle multi-language support. For example, if my regular URL is /SomeCategory/Friendly-Topic-URL, I want to have an optional language selector at the end but I'd like to be optional. So, if I get /SomeCategory/Friendly-Topic-URL/es, that should bring up the topic in Spanish but if get nothing, that should bring up English.

View 6 Replies

Mvc Routing With 2 Parameters/unable To Show The Picture

Nov 15, 2010

I want to do a hyper link such as this

<img src="../Thumb/1342526/1" alt="" /><br />
/thumb(controler)/item number/picture number within item number

my route as I thought is could be [Code]....
it does not show the picture so I assume this is not correct?!#@*(#!&@

View 3 Replies

MVC Routing - Multiple (Optional) Search Parameters

Nov 26, 2010

I'm trying to implement a search function on an incident logging page that is working fine. Currently I am only able to search against one criteria at a time, using the following route:

View 2 Replies

C# - How To Point URL From Global File Using URL Routing 3.5 Without Parameters

Nov 26, 2010

How to point url from Global file using URL routing 3.5 asp.net without parameters?

For example:

[code]....

View 1 Replies

Caching - Exclude Routing Parameters In VaryByParam?

Apr 17, 2010

I have a routing setting in my global.asax file:

routes.MapPageRoute("video-browse", "video/{id}/{title}/", "~/routeVideo.aspx");

My routeVideo.aspx page has caching setting:

<%@ OutputCache Duration="10" Location="ServerAndClient" VaryByParam="id" %>

But when I request http://localhost/video/6/example1 and http://localhost/video/6/example2 after this, the page is created again. So I think VaryByParam works for * but I only want compile when id changes. Is there a way to define routing parameters at VaryByParam?

View 3 Replies

Configuration :: WebForms Routing In 4.0 Multiple Parameters?

Oct 18, 2010

Simple enough I have a search feature I am wanting to impliment Routing for.Here is the routing table for it.

[Code]....

Now I want to set the postback URL for a linkbutton to go to the search page with all parameters filled in but the last one or for that matter any one of the parameters to be left blank

[Code]....

You will see in this example I left the very last one blank. Now when I do that the link does not work. If I fill in all attributes it does workso can anyone tell me how to work around this issue?

View 2 Replies

MVC :: Routing Is Correct, But Parameters Don't Reach The Action Method.

Jul 1, 2010

I've been struggling for some time now with an MVC routing issue, but I have finally reached a point where the basic routing is correct; that is, the application is invoking the correct action method and .aspx page, but the action method fails because no parameters are passed to it.

Before I show detailed screenshots of the problem, I had better provide some background. This is a bibliographic application which, among other things, analyzes text abstracts to identify unique words and the number of occurrences for each word in each document. This data will eventually be inserted into a SQL Server database, but for the time being I only want to do the calculation and display the results, on a document-by-document basis, in an .ASPX view set up for the purpose. The data structure of the application is as follows:

Collections -this is a set of fifty or so CollectionDetails items.CollectionDetails represent individual documents, in this case books in an academic library. Attributes of the CollectionDetail record are those typical of a library book--author, call number, title, year, and so on. The title and subject catalog headings are combined to form a quasi-abstract, which becomes the basis of the text analysis. In a few cases, I added additional text from Google Books or Amazon synopses and reviews.

MasterStopList contains common words such as pronouns and prepositions that we want to exclude from consideration.

View 8 Replies

MVC :: Routing Displaying Different Pages With The Same Url With Optional Parameter?

May 27, 2010

I would like to have two different welcome pages for a site.How could I handle this? I've looked at routing but I'm not sure if global.asax.cs is the correct place to place this into.

www.mycompany.com should display generic information. Displaying view Home/Default.aspx
www.mycompany.com?id=1 should display welcome customer x. Displaying view Home/Welcome.aspx

View 2 Replies

HttpHandlers / Modules :: Routing Classic ASP Pages To New 4.0 Site

Sep 24, 2010

We have recently migrated one of our legacy websites (classic ASP) to ASP.Net 4.0. I have already created a RegisterRoutes() in Global.asax (as per [URL]). I am concerned about SEO rankings and link breakages with external sites linking to old site.

Ideally, I will like to: Load all the routes from an XML file within RegisterRoutes() --> As there are 100's of pages with no naming convention followed. We have already created mappings within an excel spread sheet which can easily be exported to XML.Action Permanent redirects from within RegisterRoutes() --> to avoid having landing page(s) performing Redirects like Response.RedirectPermanent() and Response.RedirectToRoutePermanent. Has anyone run into a similar situation? Is there a better way of handling this situation?

View 1 Replies

C# - Url Routing From Hierarchical Tree Of Pages Stored In A Database?

Mar 2, 2010

I have a bunch of html pages stored in a mssql database. Each row has:

ID
PageTitle
Page Html Content
ParentId

ParentId is there so i can create a hierarchical tree of pages.

Currently i am using this line of code in order to access the pages...

routes.MapPageRoute("front", "{PageTitle}", "~/front.aspx");

Which then causes a redirect to front.aspx so i can then use:

Page.RouteData.Values["PageTitle"].ToString()

In order to grab what i need so i can display the appropriate page in the browser.

However, can anyone suggest how i would amend 'routes.MapPageRoute' so it supports an infinate hierarchical tree like i have in my database. Essentially i want to be able to type a url like: http://localhost/PageOne/SubPageOfPageOne etc

View 1 Replies

Web Forms :: How To Display Pages From The Last To The First Number In DataPager

May 28, 2010

How to display pages from the last to the first number in DataPager? Is there any tricks or I can do this with standart properties? I use Repeater with LinqDataSource control.

View 2 Replies

Prevent Normal Request To .ASPX Pages When Implementing URL Routing

Nov 18, 2010

I am using URL Routing in my .Net Web Application. I would like to prevent users from being able to access the .aspx page.

Example:

Actual URL - [URL]

Routed URL - [URL]

I want users to be able to access the page only by going to /Testimonials, but I would like to setup /Testimonials.aspx to redirect to its route at /Testimonials.

Is there an easy way to do this for Routed Pages throughout the application?

View 1 Replies

Web Forms :: Pagination - Dynamically Generating Buttons According To Number Of Pages

Aug 2, 2012

My application I am using pagination.Using pagination i bind the records with listview control.

I generate the buttons dynamically according to the number of pages which is calculated from number of records returned from dataSource.when i click on a dynamically generated button its corresponding event handlers methods should get evaluated.Since asp.net page is stateless I can't keep the state of that dynamic controls after any postback.

Just Now I have seen the Article "How to get the Id of Control that cause postback in asp.net?". I got some idea from that article. Any example for "Creating link buttons dynamically and handling its corresponding event handler in Asp.Net".

View 1 Replies

C# - How To Reduce The Number Of Parameters In An ActionResult In MVC

Feb 15, 2011

[Code]....

Is there any other way to make this more efficient?

View 2 Replies

Passing A Web Service An Unknown Number Of Parameters?

Apr 28, 2010

I'm relatively new to utilizing web services. I'm trying to create one that will be accepting data from a ASP.Net form whose input controls are created dynamically at runtime and I don't how many control values will be getting passed. I'm thinking I'll be using jQuery's serialize() on the form to get the data, but what do I have the web service accept for a parameter? I thought maybe I could use serializeArray(), but still I don't know what type of variable to accept for the JavaScript array.

Finally, I was thinking that I might need to create a simple data transfer object with the data before sending it along to the web service. I just didn't wanna go through with the DTO route if there was a much simpler way or an established best practice that I should follow. Thanks in advance for any direction you can provide and let me know I wasn't clear enough,

View 3 Replies

Manage Parameters On Pages?

May 25, 2010

I've 2 pages and I've to send some ID from first to second page

I don't like to use sessione variables and cookies, now I've:

<asp:TemplateField ShowHeader="False" ItemStyle-Width="30">
<ItemTemplate>
<asp:Button ID="btnDetail" OnClick="btnDetail_Click" id1='<%# Eval("id1") %>' id2='<%# Eval("id2") %>' runat="Server" CausesValidation="False" Text="Dettaglio" Width="60px" />
</ItemTemplate>

[Code]....

Is there a solution for don't show parameters un browser URL and don't allow users to changes the ID and view other records?

View 2 Replies

DataSource Controls :: SqlDataSource Variable Number Of Parameters

Mar 7, 2011

I should perform a Query like this Select * from produtcts where model like @MODEL Now if model is selected from combobox, it should be Select * from produtcts where model like '%MODEL1%' while, if selected chooise is null, it should be like each element in my combobox. how should i do this (in SqlDataSource)

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved