views:

287

answers:

2

My Silverlight application, using the navigation framework, has very pretty endings to its URLs, due to use of the URI mapping it does. But the front end still looks nasty, like:

http://server:port/SilverlightPage.aspx#/uri-mapped-portion

How can I get the "SilverlightPage.aspx#" portion to look nicer, preferably removing the ".aspx#"?

+1  A: 

You could use the default page instead of SilverlightPage so that it would be just:

http://server%3Aport/#/uri-mapped-portion

Another way to get prettier pages is to use something like ASP.NET MVC which has pretty urls also. Then you could have something like:

http://server%3Aport/Silverlight/App1/#/uri-mapped-portion

Bryant
But even with either of those methods, there's no way to get rid of the "#"?
Dov
The # is important because it means you can change the URL without the page reloading. It is a trick that components like Silverlight use to have changing urls without the page actually reloading. The # is only evaluated on the client side which is why that works.
Bryant
Hmmm, I tried your first suggestion, since it's easiest, but now I still see Default.aspx# in the url. I now appreciate why the # is there, but what about the "Default.aspx"? Is this strictly a consequence of running it from the ASP.NET Development Server and it won't show up when I drop it into an honest-to-goodness IIS server down the road?
Dov
Yes, that is an issue with the dev server. You should be able to just delete that and your app should still run, but I'm not 100% sure that works in dev mode. It works for sure in IIS.
Bryant
+1  A: 

You could use URL routing which is available as part of ASP.NET MVC or regular ASP.NET http://msdn.microsoft.com/en-us/library/cc668201.aspx

Edit: To answer your question in the comment:

I haven't worked with this myself, but if you look at the "Using routing with WebForms" section, it should explain it in detail. From what I gather you could use

routes.Add("SomeRoute", new Route("SilverlightPage",new CustomRouteHandler("~/SilverlightPage.aspx")));
Jacob Adams
Thanks, but what would the routing string look like in this case?
Dov