Override ApplicationRoot in ASP.NET - c#

I'm messing around with the cheapest .NET Arvixe server for learning purposes and try to install an application (Umbraco in this case) in a particular way.
Arvixe count's subdomains as websites, which means I'm currently limited to 6 of them. With some clever URL Rewrite trickery, I managed to setup the following structure.
FTP-folder:
> mydomain.com
>> wwwroot
>> subdomains
>>> subdomain1
>>> subdomain2
>>> etc.
wwwroot is the main website, under which I added Virtual Directories for each subdomain. So if in the browser you would go to http://www.mydomain.com/subdomain1, you'll end up seeing whatever app is installed under subdomains/subdomain1.
After applying some URL Rewrite, I can go to http://subdomain1.mydomain.com, and it will show me the same content as if I would go to http://www.mydomain.com/subdomain1
Now this is where the problem I'm experiencing begins.
Whenever in code I would do a relative path (eg. ~/Blog/Test/123.aspx), it will resolve to http://subdomain1.mydomain.com/subdomain1/Blog/Test/123.aspx. This all still works, as the everything is still under a single website, I just don't want the /subdomain1/ part in the URL. If I manually remove the /subdomain1/ part, the page also render fine due to my rewrite rules.
After some searching I found out that internally, whenever code has to resolve a ~/-url, it will use HttpRuntime.AppDomainAppVirtualPath for that.
How can I trick ASP.NET into thinking it's hosting under the Virtual App Path of '/' rather than '/subdomain1/'?
I have tried a few things which do not work (or I just did it wrong):
- Thread.GetDomain().SetData(".appVPath", "/");
- Make a VirtualPathProvider
In all cases, it will throw exceptions.
Is hosting under it's own website really the only solution (which means I have to upgrade the account)?

I tried all kinds of hacks by means of Reflection, so it's certainly not possible by normal means. In the end I got as far as confusing IIS, as the ApplicationRoot wasn't overwritten on all locations. So I gave up, it's not possible.

Related

To Change the Jquery version of a ASP.NET App

Currently I need to change the jquery version from 2 to 3 of an ASP.NET that is running on an IIS Server.
A vulnerability scanned our server and it created a incident to solve.
I found the file "<IIS_Directory>/Views/Index.cshtml" that has the Javascript references.
#Scripts.Render("~/scripts/vendor")
When I access from a browser I get several scripts instead of ' #Scripts.Render("~/scripts/vendor")'
How do I change the result of the '#Scripts.Render("~/scripts/vendor")' in a production environment?
Constraints
I Only have the publish folder.
At the moment I don't have the code source. until I have the code source I have to apply a patch.
I think you can't do this without source code.
The JQuery library is imported into the BundleConfig.
I think it may be a solution, although not optimal, replace under Scripts JQuery's files with same file of version 3 and give it the same names.
#Scripts.Render("~/scripts/vendor")
Is used to render a script tag (you said there was more than 1 so the bundler must be in debug mode) but the configuration of that bundle will be done in .NET code so you cannot realistically change that without the source code.
Perhaps you could update the actual jQuery source files (using the same file name) on the server and you may get lucky that nothing being used by the other scripts uses anything that has been removed in the move to version 3.
The only way to do it properly and not risk breaking the site is to do it in a proper development environment with the full source code and a proper regression test of all of the sites features.

Cannot create new GSuite accounts w/ Alias as of 2021-11

I'm trying to create users in Google directory using the Google Directory APIs, specifically Google.Apis.Admin.Directory.directory_v1. If I add a user with an alias, it will fail with an error of "If-Match - Error with format of alias" but if I create the user first and then add the alias afterwards, it succeeds.
The really strange thing is that this used to work. Starting somewhere around November 2021, code that I've had working for a few years stopped working.
I would recommend keeping user and alias creation as two separate API calls. That way if one fails you know whether it's the user create and primary address that's the problem or the alias address which is a problem.
Having said that, can you show your full API call including the POST url and body?
big shot in the dark, seems they increased their sensitivity and added more limiting on their servers "Cloud IoT Core automatically limits projects that generate excessive load"
Especially if this script used to work fine, try using a backoff script.
https://cloud.google.com/iot/docs/how-tos/exponential-backoff
if not, I tried ^^

Virtual Path Problems

I am currently trying to create multiple Applications within a single IIS-Website automatically.
Each application represents a Feature-Branch of a developer/feature.
The problem is, that the legacy application is not really made for running in a path that is not on the root. So the path the application thinks (and must think) it is running in, must be '/'.
It would come with re-structuring and re-testing pretty much everything related to urls, to change this. So for now, its not an option.
What i currently have:
[Features (Site)]
- [Feature_A (App)]
- [Feature_B (App)]
This results in Feature A being available under http://server/Feature_A and Feature B respectively.
Now when the Request reaches the application, the application must think that the url in which it was called is "http://server/" (or the Path being "/").
Chosing the correct app was achieved with the IIS URL-Rewrite module, and works quite well.
I use a cookie to decide which app to call, and the original '/' is rewritten to '/Feature_A/'
But now, when trying to eliminate the "/Feature_A" part of the Path within the app seems to be quite impossible.
Application.Context.RewritePath(newPath); // throws exeption -> different application
didnt really work out, because the new Path '/' points to a different application, and RewritePath doesnt like that.
Is there any way within the app or even in IIS to make the app think it is running on the root path?
Thank you in advance.

How do I get the generated domain name for local URL's for a Windows 8 app?

I have a Windows 8 app that downloads the online assets, unzips them into the LocalState folder, and accesses that content when the user is offline. I use a custom IUriStreamResolver to provide the content. The local URL might look like this:
ms-local-stream://package-name_application-key/.../.../
The part I'm after is the application-key. While the package-name is in the Package.appmanifest, the application-key is not. I've also verified the package-key is not part of the LocalState path. I'm wanting to use WebView.BuildLocalStreamUri and it requires the contentIdentifier, this is documented as the concatenation of the package-name and application-key.
I've done quite a bit of digging through the API's via the Object Browser, and of course I've pretty much exhausted Google and DuckDuckGo (love that search engine BTW), and they've not provided any fruit.
Does anybody know how I can get at that key the app generates and uses for this?
Apparently it doesn't actually matter what the value is. It has no bearing on the URL that is formed. I wanted to answer this for the next person trying to use this method. It just cannot be null or an empty string.

Rerouting all ASP.NET pages

I am looking to rewrite all ASP.NET pages to a uniform structure. Something like:
/Content1/Page1.aspx -> /Page1
/Content1/Page2.aspx -> /Page2
/Content2/Page3.aspx -> /Page3 (note
different sub-dir)
/xyz/Page4.aspx -> /Page4
Is this possible?
URL Rewriting seems interesting... Will it also comply with my web.config security rules (ie. address access only to /Content2/Page5.aspx should remain in force when browsing to /Page5).
If you're using IIS 7+, you can use the IIS URL Rewrite Module from Microsoft (link).
If you're using IIS 6, take a look at ISAPI Rewrite. I used it a little and it seemed to work pretty well.
Have you looked into URLRewriting? I suppose you could do it with URLRouting as well, but I'll let someone else answer that route.
EDIT:
Another option is that if you know the EXACT file path for each file, you can hard code each path using URLMappings

Categories

Resources