Using 1 sitemap but dynamically change the target location of each link - asp.net

I have a sitemap file in my project. None of the links on this file are contained on our server. They all are located on another project. We need this sitemap to mimic the navigation of the original site.
Right now the url is setup like this:
url-"~/folder a/file.aspx"
What I would like to do is dynamically change the server location of these links. Is there a way to do that?
Basically I don't want to have to hard code the dev.server or the prod.server in the sitemap.

Your best bet is probably to create a custom XmlSiteMapProvider with a "base URL" property that your URLs will be appended to. You can then change your base URL to the appropriate site (dev/prodction).

Related

IIS with VBNet Aspx, how to setup/config a site (programmatically or not) to have a folder

I have IIS, using Aspx with VBNet.
I have a site ex. mystockmarketeg.com
I have many pages of the assets of the market, e.g. I use the ? and cod=THEASSET to change the page I want to display e.g.:
mystockmarketeg.com?myinsidepage.aspx?cod=ASSET1
mystockmarketeg.com?myinsidepage.aspx?cod=ASSET2
mystockmarketeg.com?myinsidepage.aspx?cod=ASSET3
Just changing the cod parameter I can access different pages.
But I think this doesn't perform very well on google.
So I want to have a url like this:
mystockmarketeg.com/ASSET1
mystockmarketeg.com/ASSET2
mystockmarketeg.com/ASSET3
Is there a way programatically in ASPX VBNEt or changing some property on ISS to do it without the need to create folders and putting the index page on each folder?
Configure ASP.NET Routing to achieve this result. Note that if you have hyperlinks with dynamic URLs, the URLs should be generated using <%$RouteUrl:...parameters...%>.
See also a detailed ASP.NET Routing description.

How to get project URL within the application?

I need to obtain my project URL so that I create a link to another section of my site when say for example new content is added I can append this location onto it.
Is there a way I can obtain this address
http://localhost:56672/ or http://mywebsite.azurewebsites.net/
If you are creating links manually you should just use a relative URL instead of absolute. So instead of:
http://mywebsite.azurewebsites.net/some/link/here
Use this:
/some/link/here
The browser will automatically fill in the hostname.
If you are linking to an action method, then you should be using Url.Action or Html.ActionLink.

I want a completely separate page from my Wordpress-installation

I have a wordpress-driven project and want to add 1 single page to that project, that has entirely nothing to do with wordpress at all, but just consists of plain html - no links from the one to the other; nothing. This page shall be accessible via abc.com/folder while the original wordpress-project is still all over abc.com
What would be the best way to do this? Just add the folder and page, or do I also need to do something on the htaccess-file?
thanks
Just create that folder and name your html index.html inside that folder. This way that html file can be accessed via abc.com/folder

How can I generate my page breadcrumb, using web.sitemap, when my webpage can be accessed from multiple paths?

I am using web.sitemap to generate breadcrumbs in my website, but I have a page that can be navigated using multiple paths.
Is there a way I can support multiple paths using web.sitemap? If not, what is the alternative?
a standard and valid web.sitemap can't have duplicate urls ,so
I can think of 3 solutions :
1- take one path as standard path and define that in your web.sitemap
2- another choice is to set SiteMapPath control's links urls programmatically based on how the user has came to the page .
3- and another solution could be using Url-rewriting . for each path that ends with this page create a separate url . this way you might could avoid duplicate urls

Image disappear when url route

I am writing a web page to show image (image is dynamically generate by .Net charting) in a web. I have used the asp.net web forms URL routing to navigate to this page. Once I use the URL routing the image appear on the page. Anyway this is working fine for normal page browse.
More than likely your link to the image is using a relative path, and once you introduce routing you are working with a URL structure that appears to be deeper nested in the folder structure than it is.
When linking to the image for display I would recommend using root relative path something like /Images/MyFile.jpg rather than ../Images/MyFile.jpg, or similar.
This way if your route changes, and additional "folders" appear in the route, the link will still work.

Resources