ASP.net URL problem: Website Domain not appearing on front of URLs - asp.net

I create a menu structure from a compiled class that returns an unordered list with ~/ menu options. On my localhost, they show up as http://localhost:port/applicationpath/Default.aspx
I actually have to pass the Application Path to the function to prefix the URLs. The problem, however, is that we moved the application to our development server, and now the URLS show up as:
http://default.aspx/?id=1
http://folder/default.aspx
The website domain doesn't seem to be displaying. Anyone have any clue? Is this an IIS issue?

Ended up using a getRootURL() function within my javascript to do the job.

Related

Nextjs dynamic route being catched by index page

I have a next app deployed in aws. I'm having an issue with dynamic nested routes, the issue is that given a route eg. /contacts/[contactId].
On my local env if I go to that route, the page renders correctly, if I refresh it it renders correctly as well.
Now on the server it behaves differently, since going to that route while navigating the site will work as intended but if I refresh the page or try to access it by pasting the url in the browser, the one that will catch the route is the index file inside my pages directory, not the nested route.
Has anyone faced this issue? Thanks in advance.

browser-sync not working with single page application

I have a single page application that does not use hash URLs I want to use the history API. I am using the middleware historyApiFallback() in browserSync server options. However, this is only working for one level deep URLs:
http://localhost:3000/main correctly resolves to index.html
BUT
http://localhost:3000/main/a is NOT working. The browser shows "connected to browser sync" and then a blank page is displayed.
Anyone knows what could be the issue here?
The issue was that the URLs for js and css resources weren't correctly setup. This post helped me fixed the issue: mod_rewrite to index.html breaks relative paths for deep URLs

ASP.NET page formatting does not works

I have deployed an ASP.NET website on IIS 7. I was able to access my site using the URL http://**local host**/sitename.aspx and all the formatting of my pages is looking good.
But when I access the same page by using the URL http://**servername**/sitename.aspx from another system or on the same server where I have been deployed, the page formatting is not working properly.
What would be the best solution for this? Thanks
First a fall to check your Js/Css file path where you have not mention static file path with localhost name.
For more detail go to browser and browse your url and press F+12 so development tool will be open and check there for broken url.
I am not sure why you are worrying about formatting soo much. I mean formatting should not affect you much unless you use <pre> in your html.
There are ways to modify the HTTP Response Using Filters. Can you please makesure none of these filters present in your application for release mode.
Generally i use HTTP compression feature of IIS to compress my content, but in browser it looks correct to me.

Relative Links with Extension-less URLs

I have an ASP.NET 4.0 application that implements URL routing. This gives me page URLs with no extension (e.g. /Articles/{title})
Some of these pages contain relative links. When I test the site from Visual Studio, relative links point to /Articles/{title}/mylink. However, when I deploy my site to a shared hosting account, the same relative link points to /Articles/mylink.
You can see the problem at http://blackbeltcoder.com/Articles/asp/creating-website-thumbnails-in-asp-net. The link to an image near the top is broken. This page worked fine when testing from Visual Studio. {title} was assumed to be a directory. But, once deployed, {title} is assumed to be the page name.
If I append "/" to the URL above, it works as expected. But how can I make sure it always works?
Can anyone help me understand this?
After extensive tests with both this website and another one that also uses URL routing, I'm finally able to define what is happening.
I'm going to describe the way this site behaves on the hosting account as "normal". It's the same way my other site works on both the hosting account AND when run on my desktop. (Although the other site doesn't use relative links this way.)
The odd case out is when I run the new site on my desktop. The browser automatically appends "/" to my routed URLs, as though they are directories.
And the reason it does this is because I have created physical directories with the same names! If I delete the physical directory, it treats the URL as a reference to a file.
So the main problem for me is that I developed the site while testing with this odd case. Therefore, the solution is either A) make sure "/" is appended to all these links so they are considered directories, or B) alter the directory structure I've designed.

ASP.NET theme not rendering correctly

I have a small web application which uses themes. The themes work on host, so on preinit, if the host = a, load x theme, if the host = b, load y theme.
In my code this looks like:
If request.url.host.contains("a") Then
Page.Theme = x
Else
request.url.host.contains("b") Then
Page.Theme = y
I have a url which is a.abc.com and another which is b.abc.com (well it is this structure, but the letters are meaningful/company names). Problem is (and I have done host == ""), when I debug my site on localhost (another clause in the above if block where host = localhost), the style renders perfectly. Alignment of elements are perfect as I expect with the numerical values I have provided for width, margins, etc in the css. But when I use the publish tool of VS2008 (with updatable ticked), and upload to a.abc.com, which has the same stylesheet as localhost (a copy in its own folder), there are all sorts of alignment issues as if I have done no work. Why do my styles render incorrectly # runtime? If it helps, I am using VS2008 Pro Edition, IIS6 and Windows Server 2003.
What is frustrating is that the page source indicates the theme is loading ok, as it is referenced in HTML head. So when I publish, the theme for a.abc.com is loaded and referenced. Other than all this information, there is no obvious sign of what the problem is. I haven't tried to conventionally reference a single CSS file in the ASPX markup, but if I did and this worked, then it doesn't explain the problem either, anyway.
Thanks
Are you setting the Theme early enough in your code? A Theme must be applied to a page very early in the request lifecycle, in the PreInit event, if you do it in code-behind.
Yep, it is on page preinit.
I think it is to do with forms authentication. If I view (not debug) the login page, it picks up the localhost theme and everything is displayed correctly. The login control is in the middle of the page, as it should be, etc.
But if I debug the page and, as you'd expect, the login page is the start/default page, the login control appears to the left as it does when I deploy and the source indicates the css for the appropriate host has been picked up - only when I debug, there is no style applied until I login.
Are you using the built-in web server? When running in ASP.Net Development Server, the styles in App_Themes won't be used on any unauthenticated page (such as Login.aspx or ForgotPassword.aspx). That's because the user doesn't have browse permissions on that folder yet, or the App_Themes folder lacks browsing permissions. Apparently, IIS handles this but Cassini doesn't.
Try adding this to web.config to let Themes and styles work before authentication.
Or, if possible, switch to running the app on IIS on your machine.
I have enabled and installed all the sub features in
Internet Information Services --> World Wide Web Services --> Common HTTP Features
This solved by Theme not working problem.

Resources