ASP.net master pages, web root, and directory structure - asp.net

I've revised (but not changed) this question for brevity; see edits for previous version(s)
I have an ASP.net website (non-application, non-MVC) with the following (proposed) file system hierarchy:
What configuration changes (if any) can be made to implement this scheme? Is this possible? I've received the error Cannot use a leading .. to exit above the top when having targeted /Site as the application. I'm wondering if there's a way around this.
As I see it, given the site runs in C:\www\SiteRoot\ at http://example.com/:
PATH URL
~ C:\www\SiteRoot\ none
/ C:\www\SiteRoot\Site\ http://example.com/
~/Site C:\www\SiteRoot\Site\ http://example.com/
/About C:\www\SiteRoot\Site\About http://example.com/About/
Therefore, MasterPageFile="~/Site/About.master" will still resolve correctly,
as will <img src="/About/ImageInAboutFolder.jpg" />. Hopefully this sort of configuration is possible.

If I understand your question correctly, no, you can't.

Related

All website links broken when behind NGINX

I have a website, w1, on server A and on server B I have an NGINX installation.
From my development machine C I can navigate to b.uk/w1 and can see my home page, physically located on A. However, when I click a link to go to page p1 the link doesn't have my application part, w1, in the url.
I expect b.uk/w1/p1
I get b.uk/p1
Is this an NGINX thing? or do I need to rewrite my application so all links (including .js and .css) have /w1 prepended to them? This seems ugly. What if Its w2 somewhere else? do I need to version by server application therefore?
Is there a way I can get the website to treat /w1 as part of the domain? I guess this depends on what I used to build it?
Maybe there is an nginx setting I am missing. currently my location block is very simple:
location /w1/ {
proxy_pass http://A/;
}
Thanks
I couldn't find a way to achieve this. the work around was as follows:
https://www.billbogaiv.com/posts/net-core-hosted-on-subdirectories-in-nginx
Of course, this was the solution for me, given that the application I was writing was done so using asp .net core. It'll most certainly be different for other scenarios. The general idea is this;
asp .net core has some functionality to prepend to the relative links it generates, for hrefs in a and link(css) tags, src in img and script tags etc the location part of your url from your nginx configs location block, as you specify it in some config (either application.json or hardcoded in your app start logic).
If your framework of choice doesn't support this natively you'll to build this in.

DotNetNuke URL rewrite issue

I would like to shorten this: http://www.example.com/desktopmodules/imm/ims_cddetail/playtrack.aspx?trackid=18353
to http://www.example.com/playtrack/18353
IIS is no help. It suggests http://www.example.com/trackid/18353 and when I choose that, it doesn't work anyway.
I created a virtual IIS directory in the main site called "playtrack" and pointed it to the proper path. But, I still am left with http://www.example.com/playtrack/playtrack.aspx?trackid=18353.
Any suggestions?
I was looking in completely the wrong place. Dotnetnuke's Configuration Manager has a section called SiteUrls. I simply entered a rule in that:
<RewriterRule>
<LookFor>[^?]*/playtrack/(\d+)</LookFor>
<SendTo>~/desktopmodules/imm/ims_cddetail/playtrack.aspx?trackid=$1</SendTo>
</RewriterRule>
I suggest you to read https://msdn.microsoft.com/en-us/library/cc668201.aspx, you will find everything that you need about the url in aspx. You must create custom route type, for more info please read the documentation of microsoft. Especially your question is answered in the topic which called "Adding routes to a web form application".

Plone, behaviour of URLs

The situation is the following: I created a site with Plone, developed, used, but behind a test URL. Now it has to be published, but the test URL is not appropriate and I don't want to move the site. I think, if I use a redirect, it won't be appear in the URL-bar, only in the case of site start page. Am I wrong? (The test URL should not be used, because it will be a "semi-official" site.) What do you suggest to do?
As far as I can see Plone uses absolute URLs everywhere. I can add relative URLs, but if I create a new page, a new event, etc., then they have absolute URLs on other automatically generated inner pages. Is there any way to convert these URLs to relative paths? Is there any setting possibilty where only a checkbox changes this default setting?
Plone does not store your URLs in the database. It uses the inbound host header (and any virtual hosting configuration set up with rewrite rules in Apache or Nginx) to calculate the correct absolute URL when rendering the page.
In other words - as soon as you actually point the relevant domain name to the server with your Plone instance, it'll just work.
P.S.
You should put a bit more effort into asking your question. This is just a copy and paste of a half-finished email chain where you tried to get the answer from me in private. It's not very easy to understand what you're asking.
I think what you are looking for is url rewriting to handle virtual hosting. ie to get your site to appear as if it's the root url of a domain.
This is normally done via the webserver that normally sits in front of plone. For apache, here is a howto
http://plone.org/documentation/kb/plone-apache/virtualhost
for other servers
http://plone.org/documentation/manual/plone-community-developer-documentation/hosting
You can also achieve this directly in zope (via ZMI) using something called the Virtual Host
Monster. see http://docs.zope.org/zope2/zope2book/VirtualHosting.html
PS. I don't think your question is badly worded. Plone does serve pages with a "base" tag and what appears to be absolute urls. They aren't baked into the database but it's also not obvious that the solution to getting the url you want is the VHM url syntax and a proxying frontend webserver. There is a reason why it doesn't use relative urls... which I can't remember it was so long ago.

Possible bug/issue in ASP.NET 3.5 related to Request.RawUrl property

I posted a query for 301-redirect using ASP.NET 3.5 here:
Redirecting default.aspx to root virtual directory
Based on the replies I got there, I realized there might be a bug in ASP.NET's Request.RawUrl method which is unable to return the actual raw url (without /default.aspx) when being used in a sub-directory, i.e. the /default.aspx page is inside a subdirectory.
Can someone please shed some light on this possible bug?
Thanks,
Asif
i found a good explanation here
http://codeasp.net/blogs/vivek_iit/microsoft-net/873/301-redirect-from-default-aspx-to-site-root
Thanks
If you suspect this is a bug, then the place to go is Microsoft Connect, where you can report and discuss the bug directly with Microsoft.
Edit: I was able to reproduce the look per your comments.
I was unable to reproduce the infinite loop, however. I injected code into the Global.asax Application_BeginRequest handler of a web application and got the expected behavior of a single redirect.
There are other, and IMO much better, options for handling global redirect rules. On IIS7, I use the URL Rewrite module to configure rewrite rules in IIS. You can read more about it and download it here: http://www.iis.net/download/urlrewrite. The appeal of a solution such as this is that you can customize and update your rewrite rules without recompiling the application.
Edit: I was able to retrieve the raw URL without the default.aspx (after the redirect) by using instead:
Request.ServerVariables["CACHE_URL"]
It's worth a shot.
Have you looked at the IIS settings for your virtual directory? If there is a default document set to default.aspx then this will explain the infinite loop that you are experiencing. You are telling the website to redirect to the virtual directory without the "default.aspx" and IIS is detecting this on the next request and putting it back in ad infinitum.
Right click your virtual directory, select Properties and then the Documents tab. If default.aspx is in the list then that is what you will get. The Url of the request will be passed to the ASP.NET worker process as /folder/default.aspx rather than /folder/
This is not a bug. If IIS didn't do this, you would get a page not found error.
Sounds to me like you need to investigate URL rewriting: http://msdn.microsoft.com/en-us/library/ms972974.aspx

ASP.Net error: "Cannot use a leading .. to exit above the top directory"

I'm seeing this error several times an hour on my production site and am not quite sure how to fix it. I've grepped the source code and I am not using "../" anywhere in my code to generate a path.
My application is running on IIS6 on Win2003 Server. It's using URLRewriter.Net to allow the site to have friendly URLs, and I'm wondering if this could be contributing to the problem.
I've already Googled for a solution and have found several possibilities but none have worked for me.
I've tried creating a new App_Browser file to force the tagwriter settings to use a specific HtmlTextWriter, as suggested in one of the most popular solutions, but that hasn't worked for me. I haven't seen any other likely solutions.
It's probably due to using "~/something", probably on a Hyperlink control. When the physical file is at a different directory level from the friendly URL, ASP.NET uses too many ../'s in the relative URL that it generates, giving this error. If you can't just use an absolute URL instead, I believe that you can use Page.ResolveUrl("~/foo/bar") to get the proper relative URL.
Just set the Enable Parent Paths to True in the ASP settings from your website
That solved the problem for me
Use reflector to dig into the URLRewriter.Net code.
I would give your rewrite paths another once through and see if maybe there is a path that contains a folder that either doesn't exist, has been flubbed or is in fact outside the web application. Can you post the rewrite rule here?
Are you sure that you are causing the error?. Some scripts (Code Red/Nimda) troll the internet looking for a URL traversal that looks like that error.
Is this internal or external? Is it possible that your machine is getting scanned?
I was able to resolve this issue by installing .NET 3.5 SP1.

Resources