stop expanding subfolder directory - asp.net

Im having a menu on my .master page, but my pages are in a subfolder. so everytime the page is loaded it adds the subfolder directory to the path. like this:
first load: Pages/Login/create.aspx
second load: Pages/Login/Pages/Login/create.aspx
third load: Pages/Login/Pages/Login/Pages/Login/create.aspx
And so on.
How do I solve this.

I guess your url in the menu is something like "Pages/Login/create.aspx", but it should be "/Pages/Login/create.aspx"

Use app relative paths, e.g. ~/Pages/Login/create.aspx.

Related

SilverStripe 3: Load/Create page outside of the CMS

is it possible to create a page outside of the cms?
For example:
I would like to use jquery .load() to load a segment into a current page.
Is it possible to create a html or .ss file somewhere in the theme folder eg: self-contained-page.html so if I then visit www.domain.com/self-contained-paged.html I will be able to visit this page.
While you can of course serve static files, you can also "ajaxify" parts of your page. Not sure if that's what you want to do, but in case someone else is trying to do something similar.
While you could use some fancy tools like pjax or history.js, you can also do it manually. I've recently done this with SS 2.4, but SS 3 should be pretty similar:
In your controller, add a public function so you can access it via /yourpage/load (or whatever you want to call it):
public function load(){
return $this->renderWith(array('AjaxLoad'));
}
In your templates/Layout add a file AjaxLoad.ss.
If you only want to serve that page via your jQuery .load(), simply add the content right inside the file.
If you want to use the piece of content both on your regular page and want to replace it with the ajaxified version, use <% include PageSnippet %> both on the general and the ajaxified page. Then simply define your content in templates/Include/PageSnippet.ss.
You can see it in action at http://www.contentaward.at/content-lab-vienna/608#details (click on the small images at the bottom of the page). Hope this makes it clear.
there is no problem with serving static html files from anywhere in your silverstripe installation, just note to always add the file extension to your urls, as otherwise silverstripe's url routing (using mod_rewrite, see the .htaccess file) will kick in.
also note to always use the full path to the file, so in case you placed your file in 'themes/mytheme/test.html' the url will be 'http://www.domain.com/themes/mytheme/test.html'
You can of course reference a html file in the theme folder just as you would do with a css file, f.e. :
www.domain.com/themes/yourtheme/self-contained-paged.html
If you dont mind to not have it in the theme folder you can also place it into root dir.
Or you can modify your .htaccess and apply some mod_rewrite or redirect rules to point into the theme folder.
If you want to use .ss files you probably have to use CMS pages.

ASP.Net pages relative paths?

I have a website which i run localy and the path on the browser is
"http://localhost:3184/basel/index.aspx"
I have a menu which contains various hyperlinks and one of them is:
//This will evaluate to http://localhost:3184/basel/en/open-account/index.aspx.
The hyperlink will redirect me the page above, After that when i try to click the same link again on the menu, the path of the page is the following:
"http://localhost:3184/basel/en/open-account/en/open-account/index.aspx"
Why is it that the path have duplicated, i have been struggling for a while but can't seem to figure this out, Any solution ?
Try this:
Using the tilde creates an application-relative path.
What is in your code behind? If the A tag is being set dynamically (maybe something like this myHyperlink.NavigateURL += "en/open-account/index.aspx";) then each time the page is loaded the URL will have a new value appended to the end.
Maybe check the code behind to see if this URL is being manipulated there? If you've already done so, my apologies :)
Use Page.ResolveUrl() method. If the relativeUrl have an absolute URL, the URL is returned unchanged. If the relativeUrl have contains a relative URL, that URL is changed to a relative URL that is correct for the current request path, so that the browser can resolve the URL

Problem with content page in a different folder than master page

I have put the master page in the main directory and content page in a different folder in the same directory. When I try to debug the page, it does not show me any error but the images on the master page are not visible. The content page works fine if it is in the directory itself without any folders. Can anyone let me know if I am missing something here.
You're referencing images in the master page using relative paths, relative to the location of the master page.
Since the actual page is in a different folder, those relative paths are incorrect.
Instead, you should use absolute paths, or call the ResolveUrl function to generate absolute paths from application-relative paths.

Path to css and images

For example I have site http://localhost/site
In IIS I set that 404 error causes redirection to default.aspx
If I type something like http://localhost/site/nodirectory , (there are no such folder) all works perfectly.
But if I only add slah at end http://localhost/site/nodirectory/, page can't display css and images.
Images and css are located in their own folder. I tried different paths: "gfx/logo.gif", "/gfx/logo.gif"
Does anyone have some ideas about that?
If your css and images are relative paths, say ResolveClientUrl("~/gfx/logo.gif") this renders to the client as src="gfx/logo.gif", which the browser with a slash thinks is /nodirectory/gfx/logo.gif instead of just /gfx/logo.gif.
To resolve this, don't use .ResolveClientUrl(), use .ResolveUrl(), this will make the src render src="/gfx/logo.gif" The beginning / makes it definitive, it's that path from the root of the domain.
You'll see this same hebavior if you're doing paths that start with ../ or gfx/ yourself...make them relative to the application base so there's no chance of confusion.
There are a couple of options...
1)
In your HTML page, make the path to CSS and scripts relative...
"/scripts/myscript.js"
Where the scripts folder is the first folder after the root folder
2)
You can add the base tag to your page, which means ALL page resources will be treated as relative to the root location you specify...
<base href="http://www.mysite.com">
More info about these two options.
If you can, option 1 is perhaps a bit cleaner. You know explicitly the resources that you are affecting. Using the base tag will affect ALL relative paths on your page. Images, Links, Scripts, CSS et al. The second option works best if you developed your 404 page assuming it would be in the root folder, but it could actually be referenced from any non-existent directory. You just put your root address in the base tag and it will all behave exactly as you expect.
With either option, the images can be relative to the location of your CSS file.

Drupal paths in themes

On certain pages drupal_get_path isn't working correctly (or it is and I've got the wrong function)
The base path is wrong
Example:
Image is supposed to be at
http://domain.com/sites/all/modules/pecapture/images/headline_dontmissout.jpg
But when on
http://domain.com/node/9
The URL is
http://domain.com/node/sites/all/modules/pecapture/images/headline_dontmissout.jpg
The same happens on the page
http://domain.com/admin/build/ and block edit page
How do I get the right path?
added base_path() to beginning of my paths...
base_path (http://api.drupal.org/api/base_path), if you use php code.
In html case, just add "/", like: /sites/all/modules/pecapture/images/headline_dontmissout.jpg
One problem: if you work on subfolder (Drupal installed in internal folder of main site): http://domain.com/subfoldersite, it will not correct, becase will remove "subfoldersite".

Resources