Server Error in '/' Application, The resource cannot be found - c#

Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /public/google_setup.aspx
I am getting the above error when i host the site on the server. In my local computer it is working fine. google_setup.aspx is referring to a master page which is also on the server. I have developed other pages using that master page before and they are working fine.
Any idea what is wrong.
If someone can suggest a way to get little bit more detail information on this error i would be able to fix it

Sounds to me like you are facing a problem with relative and absolute URLs.
Try using the ~ (tilde) and runat="server" when you link to your page:
<asp:HyperLink
NavigateUrl="~/public/google_setup.aspx"
runat="server">Google Setup</asp:HyperLink>
or
Google Setup

Related

How To Rewrite/Redirect url with . in path?

I have a site, which was built by asp.net 2 by another guy long time ago. For some reasons, google indexed lots of pages whose url has . in the path (not the domain part). i.e.
http://example.com/CA/Orange/Industrial-Warehouse-Space/1411-N.-St./1234567
In the code, UrlRewritingNet is used for rewriting url. One of the rule is:
<add name="Rewrite_5" virtualUrl="^~/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([0-9]+)/*$"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/Location.aspx?id=$5"
redirectMode = "Permanent"
ignoreCase="true" />
If the url is:
http://example.com/CA/Orange/Industrial-Warehouse-Space/1411-N.-St/1234567
Note that, no '.' after 'St'. Then the url will be rewritten successfully. But if used
http://example.com/CA/Orange/Industrial-Warehouse-Space/1411-N.-St./1234567
The site always shows:
Server Error in '/' Application
The resource cannot be found.
I'm wondering whether there is a way to rewrite/redirect this url to the correct url, or even homepage? Currently, it is on asp.net 2, if needed, can change to other framework too. Any suggestions?
Thanks
I'm using UrlRewritingNet for rewrite, not sure what the actual url it is trying to rewrite when the error happens. However, I can not capture this in the customError page for 404 (it is a 404 when look at the traffic).

ScriptResource.axd not found over the load balancer

The applcation works fine when I try to access it by server1 and server2 indivisually.
But I try to access it using load balancer it gives me the below error.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /ScriptResource.axd
I have added the below line under system.Webserver -> handlers section.
Still no help.
Can anybody suggest me where I am doing wrong?
Thanks,
Joy

IIS throwing HTTP 404 not found but resource exists. Requested URL also changing automatically.!

I'm facing a really weird scenario here with my local IIS. I have hosted multiple sites in the default website in my local IIS. One of them has the login page. From the login page, I'm redirecting the user to another page that is located in another site (which is also hosted in the same IIS inside default website virtual directory).
Now in the submit button click event of my login page, after authenticating the user, I have written a "Response.Redirect(redirect_url)". the redirect_url is being formed dynamically and given as a parameter to the Redirect method.
While debugging, the final redirect_url that is being sent as parameter to Redirect method is:
http://localhost/CP/web/console/console.aspx?sk=3e3cc1a8-73c4-4945-b3f8-08af22ea4324.50008
But after I try to go to the next step, I'm suddenly getting a HTTP 404 error saying that the resource doesn't exist and I have observed that Requested URL shown in the error page is different that what was dynamically sent to the Response.Redirect(...) method.
In the error page, the requested url shows the value as
http://localhost/CP/web/console/localhost/CPLogin?err=5
whereas my actual requested url formed in the code is:
http://localhost/CP/web/console/console.aspx?sk=3e3cc1a8-73c4-4945-b3f8-08af22ea4324.50008
I'm just unable to understand why the requested url is getting changed automatically.! Also, I observe that "localhost" is being appended to the requested URL again which is not what is supposed to happen.
Please visit THIS link[^] to understand this question more clearly. I have added screen shot of the error page.
http://amoghnatu.wordpress.com/2013/09/16/question-please-help-iis-throwing-http-404-not-found-but-requested-resource-actually-exists-requested-url-also-changing-automatically/[^]
Thanks a lot.!
Indeed, the problem was with the way I had hosted the sites in my application. I just removed all the sites related to my application from IIS and then hosted all of them again much more carefully. This resolved the "wrong redirect url" problem.
Also, I had some tables with missing required data because of which I was getting the error code.
So after I got all the tables filled with the required data and also after properly hosting the application in IIS, my problem got resolved.
In IIS, go to relevant folder, right click and "browse". Check out what is the URL. In most cases, this is due to the URL should have port number appended. For instance it will be something like :
http://localhost:<port number>/CP/web/console/console.aspx?sk=3e3cc1a8-73c4-4945-b3f8-08af22ea4324.50008
instead of
http://localhost/CP/web/console/console.aspx?sk=3e3cc1a8-73c4-4945-b3f8-08af22ea4324.50008

How to Serve Static Files (in ~/Content) Via HTTPS in ASP.NET MVC3

I have an ASP.NET MVC3 application to which I've just added an area. Links inside the area (to images, JavaScript files, CSS etc.) default to https. However, MVC doesn't seem to serve static content inside the ~/Content directory over https.
I've pored over internet documentation, and I've found no information about how MVC treats the ~/Content directory differently, or how to get it to serve static files over https.
I was hoping it would be as easy as a Web.config entry that says "allow static files to be served via https" but I've found no such thing.
The only option I've come up with is to write a custom controller to serve my static content, but this seems so very wrong. What am I missing?
UPDATE: to answer Joe's question below, the views themselves are being served over https. For static content, like JavaScript files, I'm using absolute URLs without protocol or domains. For example:
<script "/Areas/Admin/Content/js/jquery.js"></script>
Because the protocol of the page is https, the browser is making a request for https://localhost:5300/Areas/Admin/Content/js/jquery.js (naturally). Make the protocol http and that file is served correctly: make it https, and I get an error.
UPDATE: I was foolishly not reading the error carefully. There's more detail in there, but it's still got me baffled. The error I get when I try to access https://localhost:5300/Areas/Admin/Content/js/jquery.js is:
Parser Error Message: An error occurred loading a configuration file:
Failed to start monitoring changes to
'C:\Users\ethan\Documents\gitwork\SampleWebSite\admin\content\web.config'
because access is denied.
Why is it looking for a Web.config file in that directory?
A simple solution is that you don't use "~"

URL Rewriting not working with URL ending ".ad" or ".cd"

I'm having some difficulties with my custom URL-rewriting setup. I'm not using any 3rd party tool to manage this, just using the global.asax by looking at every request and processing it.
The way I am using it is like:
www.mydomain.com/site/google.com
This page contains information about the site "google.com". I'm using the actual domain within the URL. This is all works fine.
I have simplified the code that I'm using just to show you an example of how it works:
Dim myContext As HttpContext = HttpContext.Current
Dim URL As String = myContext.Request.ServerVariables("URL")
If URL.ToLower.Contains("/site/") Then
URL = URL.Trim("/")
Dim strURL As String = URL.ToLower.Split("/")(1)
Redirect301("/site.aspx?url=" & strURL)
Exit Sub
End If
The issue I'm having is for certain domain extensions, the page will just load up custom 404 Not Found and I have no idea what the cause is.
Example of pages that don't load:
/site/google.ad
/site/google.cd
I'm guessing that the system thinks that .cd and .ad files are actual physical files and when it doesn't find them, it shows the custom 404 error. It doesn't actually looks like the request is getting through to the global.asax. When working in local environment, they actually load fine but only on the live server it has this issue and this is why it has been a nightmare trying to figure it out.
Another issue I found was loading the following URL:
/site/prn.com
This shows a 404 error again but this time not the custom one I created but the actual hard looking .net 404 error page. This also works fine in local environment.
There must be some IIS setting or code change I could do to try to get this resolved.
Thank you for your time :)
Aki
Check this link . Error message when you try to browse a Web page that is hosted on IIS 7.0: "HTTP Error 404.7 – FILE_EXTENSION_DENIED
This is the reason .ad .cd extensions are blocked.

Categories

Resources