Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should be able to specify something like <a href="http://www.mydomain.com/oempartnumber/oem" rel="nofollow noreferrer">http://www.mydomain.com/oempartnumber/oem</a> and <a href="http://www.mydomain.com/mypartnumber/pn" rel="nofollow noreferrer">http://www.mydomain.com/mypartnumber/pn</a>. There must be something in the url that allows you to choose the controller you want to use and further more allow you to distinguish between a part number and an oem part number (unless those are also unique against one another. If there will never be overlap between oem and pn then you could have <a href="http://www.mydomain.com/" rel="nofollow noreferrer">http://www.mydomain.com/</a>{partnumber}/pn.</p> <pre><code>RouteTable.Routes.Add(new Route { Url = "[query]/pn", Defaults = new { controller="PartNumber", action = "Details" }, RouteHandler = typeof(MvcRouteHanderl) }); </code></pre> <p>You could use some trickery with a route like this:</p> <pre><code>routes.MapRoute( "Part number", "{partNumber}", new { controller = "Part", action = "Display" }, new { partNumber = @"\d+" // part number must be numeric } ); </code></pre> <p>But the problem here is that an OEM part number that is not actually a part number (such as "ave-345") would not match!</p> <p><strong>UPDATE:</strong> In reading I noticed that you said "this is not an MVC site so I don't have controllers!"...OH! That changes things. In that case you can check to see if the directory exists where you pass in <a href="http://www.mydomain.com/1234" rel="nofollow noreferrer">http://www.mydomain.com/1234</a> and if not you can test it for a product number. This would have to be done in a HttpModule though so you can catch it before your page is executed. Then on the server side you can direct the page to <a href="http://www.domain.com/productdetails?pid=1234" rel="nofollow noreferrer">http://www.domain.com/productdetails?pid=1234</a>. </p> <p>Take a look here to understand that: <a href="http://www.15seconds.com/Issue/020417.htm" rel="nofollow noreferrer">http://www.15seconds.com/Issue/020417.htm</a></p> <p>For this you will have a class that inherits from IHttpModule. Then you can specify an Init method</p> <pre><code>public void Init(HttpApplication application) { //let's register our event handler application.PostResolveRequestCache += (new EventHandler(this.Application_OnAfterProcess)); } </code></pre> <p>This then points to your Applicaton_OnAfterProcess method:</p> <p>private void Application_OnAfterProcess(object source, EventArgs e)</p> <pre><code>{ HttpApplication application = (HttpApplication)source; HttpContext context = application.Context; ... </code></pre> <p>Inside of here you can specify some rules about what you are looking for.</p> <p>I usually do something along the lines of </p> <pre><code>if (!System.IO.File.Exists(application.Request.PhysicalPath)) //doesn't exist { //you test for your product ID here ... //if you find it stuff it into a ProductID variable for later... </code></pre> <p>Once you isolate your product ID you can then rewrite the URL (server side) and direct the user to the proper productDetails.aspx page.</p> <pre><code>context.RewritePath("~/products/productDetails.aspx?ProductID=" + ProductID.ToString()); </code></pre> <p>So while the user and google sees <a href="http://www.mydomain.com/1234" rel="nofollow noreferrer">http://www.mydomain.com/1234</a> your application will see <a href="http://www.mydomain.com/products/productdetails.aspx?productid=1234" rel="nofollow noreferrer">http://www.mydomain.com/products/productdetails.aspx?productid=1234</a> and you can code against it as usual.</p> <p>I hope this is what you were looking for instead!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload