Handle MVC Routing Along With Webform Routing

Sep 2, 2010

How to handle asp.net mvc routing along with asp.net webform routing. I have merged my mvc app into my existing web application. In my web application i have implement routing as below:

routes.Add("View Product Details", new Route("Product/{City}/{Manufacturer}/{Name}/{ProductID}/{*ProductType}"));

Similarly i have implemented routing in mvc as below

routes.MapRoute("Product Details",
"Product/{City}/{Manufacturer}/{Name}/{ProductID}/{ProductType}",
new
{
controller = "Home",
action = "ProductDetails",
City= UrlParameter.Optional,
Manufacturer= UrlParameter.Optional,
Name= UrlParameter.Optional,
ProductID= UrlParameter.Optional,
ProductType= UrlParameter.Optional
});

How to handle both pages, as one is custom web form while other is asp.net mvc view?

View 1 Replies


Similar Messages:

Routing Webform In Mvc App

Aug 6, 2010

I have an ASP.NET MVC app and I have a WebForm page I built in the MVC due to a tutorial on how to do something I needed to do, but it was all in WebForm style. Ive tried to figure out how to do the same thing in MVC format but cant figure it out. So I was needing to figure out how to use this page in my MVC app. But when I try to go to the page, it gives me the error "Page cannot be derived from ViewMasterPage unless Page derives from ViewPage." So I had to make a new standard MasterPage also.

The situation is this. I have a search bar located in the MVC ViewMasterPage thats on every page that is derived from it. Once a user submits info in the search bar, it calls the WebForm Search.aspx page and displays the results on the Search.aspx page. I want the URL to be like "http:///search//. The Search.aspx page is located in the root of the project. How would I get the results Im looking for?

View 1 Replies

.net 4.0 - Webform Routing With Javascript

Nov 14, 2010

I am using asp.net 4 routing and im enjoying it so far. I have one problem only with my javascript files. I am using a masterpage to add my css and javascript. The css is working fine however the javascript is not. My links from my masterpage look like this

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="~/_styles/css/core.css" rel="stylesheet" type="text/css" />
<link href="~/_styles/css/facebox.css" rel="stylesheet" type="text/css" />
<script src="~/_styles/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="~/_styles/js/jquery.validate.js" type="text/javascript"></script>
<script src="~/_styles/js/facebox.js" type="text/javascript"></script>
<script src="~/_styles/js/corejs.js" type="text/javascript"></script>

Why does my css load correctly but the js doesnt?

View 2 Replies

Get Started With URL Routing In Webform Application?

Feb 19, 2010

Thus far working with asp.net webforms was very easy .... But never implemented URL Routing in webforms... I know asp.net MVC Handles URL Routing pretty well... How to get started with URL Routing in an asp.net webform application? For EX: [URL] i want it to be like [URL] Any good article to start with URL Routing asp.net 3.5

View 1 Replies

Web Forms :: Web.Routing Doesn't Work On Server On IIS Routing

Jul 20, 2010

I tried everything I could find, but still does not work on IIS routing.

View 2 Replies

C# - Webform Routing Home Page In A Folder Like Mvc Rather Than Root Of Site

Aug 18, 2010

I've got webform routing setup on my asp.net webforms 3.5sp1 project. I would like to have the files for the site in a directory called content including the home page as I would like to run multiple sites using the same system. In MVC there is a blank default page and the home page is in a folder called home. I can't seem to replicate this behaviour using web form routing but would like to. The blank page is always hit first. the route handler is hit second - it recognises that the request is for the home page and sets up the routing page but is not used. the route handler code is simple:

public string VirtualPath { get; private set; }
public IHttpHandler GetHttpHandler(RequestContext
requestContext)
{
string file = requestContext.RouteData.GetRequiredString("File");
string id = requestContext.RouteData.GetRequiredString("Id");
string queryString = "?menuid=" + id;
VirtualPath = "~/" + file;
HttpContext.Current.RewritePath(
string.Concat(
VirtualPath,
queryString));
var page = BuildManager.CreateInstanceFromVirtualPath
(VirtualPath, typeof(Page)) as IHttpHandler;
return page;
}
Is there anyway I can do this?
Update
Here is my global.asax route code:
public static void RegisterRoutes(RouteCollection routes)
{
Domain.RepositoryFactory repo = new RepositoryFactory();
foreach (var x in repo.MenuRepository.GetAllEnabledGetMenus())
{
if (string.IsNullOrEmpty(x.Url))
{
//add default
System.Web.Routing.RouteTable.Routes.Add(
new Route("Default.aspx",
new RouteValueDictionary(new { File = x.FileName,
Id = x.Id.ToString() }),
new CoreRouteHandler()));
}
else
{
string url = x.Url;
if(x.Url.StartsWith("/"))
{
url = url.Remove(0, 1);
}
System.Web.Routing.RouteTable.Routes.Add(
new System.Web.Routing.Route(url,
new RouteValueDictionary(new {File = x.FileName,
Id = x.Id.ToString()}),
new CoreRouteHandler()));
}
}
}

View 2 Replies

Routing (3.5) - How To Handle Multiple TLD Domains

Jan 18, 2010

Is it possible to have one asp.net web application that handles requests from two domains via asp.net routing? I need one TLD domain per language version pointing to the same app.

How to set up a route that recognize, if the request is coming from domain1.de or domain2.com? How to configure the domains DNS for this to work?

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

Web Forms :: How To Handle 404 Errors When Using URL Routing

May 7, 2015

I have been using using System.Web.Routing for url routing in global.asax file  code is as below.

public static void RegisterRoutes(RouteCollection routes) {
routes.MapPageRoute("Home", "", "~/Home.aspx");
routes.MapPageRoute("Posts", "Posts/{blog_url}", "~/blog-description.aspx");
}
protected void Application_Start(object sender, EventArgs e) {
RegisterRoutes( RouteTable.Routes);
}

Now this works fine on local  but when i move the same to live it shows error 404 .I want to create a log actually what url is called.

View 1 Replies

Web Forms :: How To Handle Not Found Errors When Using URL Routing

May 7, 2015

I have a small problem:

Example:

RouteCollection routes
routes.MapPageRoute("Product","{ProductName}","~/Product.aspx")
Address on browser:
localhost:port/Software/VisualStudio

Error: HTTP Error 403.14 - Forbidden (because that Route is not exists).

How can i catch errors when routes are incorrect or not exist?

View 1 Replies

Routing With Web Forms - Could Not Load System.Web.Routing

Dec 12, 2010

I am using:

ASP.NET 3.5 SP1 with Web Forms Routing thru Global.asax (System.Web.Routing and RegisterRoutes)IIS 7

Everything is working fine in my local machine, but it gives the following error in my hosting environment:

Could not load file or assembly 'System.Web.Routing, Version=3.5.0.0, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I did everything inside my web.config file mentioned in the following link:

[URL]

But I am still getting the above error.

What else am I supposed to do fix the error?

View 1 Replies

Web Forms :: URL Routing - Route To Aspx Page To Handle Processing?

Aug 20, 2010

I am able to route my urls to an existing page. Here is how our scenario is currently working:

On Default.aspx, we have several links that link to pdf files on the server. The filenames of these files change dynamically which is why we need the url routing. When the user clicks on of the urls, the link is routed to the getFile.aspx page that has logic in it to determine which file to open.

Is there a way to have the getFile.aspx page to open in the same window as the default.aspx page?

Otherwise, I need for the getFile.aspx page to close after the intended processing is complete, and I've not been able to close it without getting the close window dialog box. I figure if it opens in the same browser window, I can redirect back to the default.aspx page when processing is finished.

View 1 Replies

Rest WCF Url Routing & Web Forms Routing?

Feb 22, 2011

I have a Web application where i have added a reference to a RESTful WCF. I got the WCF url Routing to work in my webapplication by adding Inherits="RestService.Global" to the Web applications Global.asax.

<%@ Application Codebehind="Global.asax.cs" Inherits="RestService.Global" Language="C#" %>

But then i tried to create url Routing for the Web application and it does not work with the Inherits="RestService.Global" in the Global.asax. If i take it away it works fine. Is there a correct way to do this.

View 1 Replies

Web Forms :: URL Routing And Dynamic Routing?

Jan 31, 2011

I'm trying to create my own CMS and I've gotten a little bit stuck at the stage of URL routing.

I want clean URLs without extensions and I'd like to be able to create and modify them in a web based interface without any messing around with IIS or actual files.

I've seen how to create a static route, but for that I need to go into my Global.asax file and manually add it.I would like to have all of these routes stored in a database so that I can easily modify them later.

Does anyone know how this can be achieved?

Just for extra information, I will be attempting to create a feature so that if a path exists, but is later changed, a 301 redirect is created to the new URL, is this also possible? (My first problem is the main issue, but thought I might ask this as well just in case it makes a difference)

View 2 Replies

MVC :: How To Permanently Redirect Url From Old Routing Rule To New Routing Rule

Nov 30, 2010

Response.RedirectPermanent(Url); can redirect permanently to a url.

However, during my SEO process, I decided to change my routhing rule.

For example,

I change "/tag/{tag}-quotes" routing rule to "quoes-about/{tag}", but I don't want to lose all the traffic to old routing url.

What is the best way to handle this permanent redirection?

View 4 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

C# - Routing Or URL Rewriting?

Nov 3, 2010

I'm currently using URL Rewriting, but I recently stumbled upon this link on Rerouting, and it looks like it's quite simple yet powerful, and easier to implement than URL Rewriting, a "downside" probably is that configurations are not sitting on a web.config file but rather on the code itself, but I was wondering about the differences, and advantages of using one over the other. Having read some resources about routing, I can see the differences, and now I reformulate my question:

Is it worth it to move from URL Rewriting to Routing?
Are there any IIS-specific configurations that should be made?
Is it recommended to use it on a ASP.NET WebForms Application, or is it oriented to other kind of projects?

View 1 Replies

Web Form (No MVC) VB.NET URL Routing

Feb 22, 2010

I've been doing research for a few days now and I know that I want to do ASP Routing over Rewriting. I found this great article:http://www.4guysfromrolla.com/articles/051309-1.aspx and also

http://blogs.msdn.com/mikeormond/archive/2008/05/14/using-asp-net-routing-independent-of-mvc.aspx. I write in VB.NET, these two articles are written in C#. I converted the code, but I must be missing something because my routing doesn't work correctly.

I was able to download the code from 4guys and it works fine. I found some differences between my results and theirs when I stepped through error checking. I added the 3 lines to the web.config file:

<system.web>
<httpModules>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0,[code]....

I right clicked on my project and added a reference to the System.Web.Routing dll.I created a Global.asax file in the root directory.

<%@ Application Language="VB" %>
<%@ Import Namespace="System.Web.Routing" %>
<script runat="server"> [code]....

Theirs shows the correct value of whatever you click on The requestContext variable, > HttpContext > System.Web.HttpContextWrapper > Request > System.Web.HttpRequestWrapper > PhysicalPath = "C:UsersNvXDesktopMyWebsiteWebResource.axd"

Theirs shows PhysicalPath = "C:\Users\NvX\Desktop\RoutingDemo\Products\Pavlova" (Pavlova was the link I clicked on)

When I query the database using LINQ, it never finds WebResource.axd and redirects to the NotFound.aspx page. When I load Default.aspx, I want it to load that page. If I type /tjnevis (which is a username in the database), I want it to go to a page where I can put together a profile, pulling the information for that username, which I can figure out. It's the routing that I'm having trouble with. If I could get it to work correctly, I think the PhysicalPath should look similar to the 4guys example I downloaded.

View 4 Replies

Routing With A Guid In MVC?

Nov 2, 2010

I have a url which will take the following form:

/AuditReview/Review/15d49a66-5c11-492c-921f-9e1700bd2618

I cannot get this to route, my routes look like this:

MvcRoute.MappUrl("{controller}.mvc.aspx/{action}/{auditEventUid}")
.WithDefaults(new {controller = "AuditReview", action = "Review"})
.WithConstraints(new { controller = "AuditReview", action ="Review", auditEventUid = new GuidConstraint() });
MvcRoute.MappUrl("admin/{controller}.mvc.aspx/{action}")
.WithDefaults(new { controller = "audit", action = "index" })
.WithConstraints(new{controller = "audit"})
.AddWithName("admin", routes);
MvcRoute.MappUrl("{controller}.mvc.aspx/{action}")
.WithDefaults(new {action = "Index"})
.AddWithName("Default", routes);

View 2 Replies

Handler Like Mvc Routing Without Mvc?

Feb 21, 2011

I used to build my web apps in asp.net in such there is only one page witch is default.aspx

http://localhost/mywebapp1/?q=blog/posts/get/42


I do parse 'q' by myself and do all processing. I don't really need to all MVC staff. I just want to remove "?q="

View 2 Replies

Web Forms ::Routing Without Using MVC?

Aug 6, 2010

This is more of an ASP.NET Routing question than MVC, so I will gladly move this post to another forum if prompted!

I am using ASP.NET Routing without using MVC.

I am trying to implement the following URLs:

[URL]

[URL]

[URL]

Each page can have sub-pages:

[URL]

or even sub-sub-pages:

[URL]

I am currently implementing this as follows:

1) GLOBAL.ASAX

[Code]....

2) ROUTE HANDLER CLASSES

[Code]....

View 2 Replies

Where To Use Route-name Of Routing In Mvc

May 19, 2010

i'm new to routing in aspnet mvc.. i have following code:

[code]....

when i enter "localhost/school" in addressbar, it is giving 404 error instead it should route to my "schoolIndex" action

i have given route-name as "School" where it is used ?

View 1 Replies

Mvc Routing Id Parameter

Apr 30, 2010

I am working on a website in asp.net mvc. I have a route

routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
ew { controller = "Home", action = "Index", id = UrlParameter.Optional }

View 4 Replies

MVC :: Asp.Net Routing With Subdomain?

May 7, 2010

I am using MVC 2.0 to create my application,my problem i s related to the routing. Actually in my application each user have required seperate subdomain,like

www.example.com/user1/ ,www.example.com/user2/ ...etc.the default domain is www.example.com.So how can i make it possible with routing in mvc.

i have tried like this,
routes.Add(new Route("{id}", new RouteValueDictionary(new { controller = "User", action = "login", id = " " }), new MvcRouteHandler()));
var defaults = new RouteValueDictionary(
new
{
controller = "Home",
action = "Index",
id = UrlParameter.Optional
}
);
routes.Add(new Route("{controller}/{action}/{id}", defaults, new MvcRouteHandler()));

But the problem is that it take deafult (www.example.com) directly to user login page.I want the default page as Home/index and when www.example.com/user1/ it will go to user login page.

View 1 Replies

MVC :: To Localize A URL / Routing In .NET

Oct 14, 2010

I'm working with a client that wants the URLs in our web application to be in French. I'm an English developer and we also have English clients. This is an interesting problem is there something int the ASP.NET MVC Framework that would enable me to do this?

Here's the scenario. The route...

Specific EXAMPLE English URL
www.stackoverflow.com/questions/ask

So in MVC my Area, Controller and Actions all need to have both English and French translations.Obviously maintainability would be a HUGE issue if I were to go and hardcode all my Controllers, Views and Action names to French. Is there anyway to localize the route that is presented in the browser without doing this? Keeping in mind there are lots of different routes in the application. A couple Areas each with a handful of Controller each with many Actions?

Note this message is also on SO: http://stackoverflow.com/questions/3935768/is-it-possible-to-localize-a-url-routing-in-asp-net-mvc

View 3 Replies







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