Server.Transfer to internal virtual application - server.transfer

My question is how to manage several virtual applications, located at the same host
firstdomain.com is redirected to firstdomain.com/1
seconddomain.com is redirected to seconddomain.com/2
and so on...
each new domain must be located at different folder, and for now it is working fine.
But it causes some inconvenient, for example seconddomain.com/1 is showing firstdomain.com web site.
i'm trying to create something like dispatch at root directory "/" to transfer necesary domain with Server.Transfer("").
but it is not working like I thought:
Server.Transfer("/" + folder + "");
causes this error:
Server Error in '/' Application. Error
executing child request for
/web_folder.
Description: An unhandled
exception occurred during the
execution of the current web request.
Please review the stack trace for more
information about the error and where
it originated in the code.
Exception Details:
System.Web.HttpException: Error
executing child request for
/web_folder.
Server.Execute("/" + folder + "");
causes error too:
Error executing child request for
/web_folder.
Description: An unhandled exception
occurred during the execution of the
current web request. Please review the
stack trace for more information about
the error and where it originated in
the code.
Exception Details:
System.Web.HttpException: Error
executing child request for
/web_folder.
both applications works fine accessed by its specified url.
and also there is a problem with two applications, if I use HttpModules from root web.config, it causes compilation error inside virtual application. It may be passed, if I add reference to same project in virutal site.
Any suggestions ?
i think there must be any solution, many people need to redirect any subdomain to a subfolder without Redirect, to keep the original URL dsplay
thanks.

You cannot Server.Transfer to an application that is hosted to a different virtual directory in IIS than the one that's performing the request.

Server.Transfer can only happen for single HttpContext. Each virtual directory or app has its own HttpContext object and they know not that co-exists! so you cannot do that.

Related

How to redirect to valid page if got 'The resource cannot be found'? Please suggest

I have a requirement to catch this exception or show some log if browse with below invalid filename :
http://localhost/ABC/xyx.asmx
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: /.asmx
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4261.0
In web.config, you have two methods to custom error page.
When the error is caused by IIS or any other but not asp.net, IIS will shows error page like these.
If you want to change them, check the custom error pages in Error Pages module. Then delete the existing status code and corresponding page path, and add a new one.
When the error is caused by the asp.net, IIS will show error page like yello screen of death(YSOD). You can change it in section. If you want to show custom error page to remote visitor and YSOD to local vistor, you can set mode to RemoteOnly. You can configure this in .NET Error Pages Module.

django error reporting request url - how to use this locally?

I have a django project which used the normal email admins on an unhandled exception when debug is set to False. ie in production.
I normally just review the error message and the stack trace. However I clicked on the request url link, which managed to recreate the error on the prouduction site (which then fired off another email).
What is this request url? Does it recreate the full http request (including the session etc..) which resulted in the original error?
Can I get the link to point to a local version of the site? (As after fixing a previous error clicking on the earlier request url has manged to create a recent error that we have been unable to reproduce, so it would be good to recreate this locally so it can be debugged.

Azure Web Site with Django 500 Error

I've spent over 8 hours trying to get this Django site up and running on an Azure Website. I've nearly thrown in the towel would really appreciate some help.
So far I have tried numerous methods and followed different tutorials, but they have all yielded the same result. Here is the most recent tutorial I have followed: http://www.windowsazure.com/en-us/develop/python/tutorials/web-sites-with-django/
Now that my site is "up", I am seeing a 500 error for all requests. Here is the error in the log:
The page cannot be displayed because an internal server error has occurred.
Most likely causes:
IIS received the request; however, an internal error occurred during
the processing of the request. The root cause of this error depends on which mo
dule handles the request and what was happening in the worker process when this
error occurred. IIS was not able to access the web.config file for t
he Web site or application. This can occur if the NTFS permissions are set incor
rectly. IIS was not able to process configuration for the Web site o
r application. The authenticated user does not have permission to u
se this DLL. The request is mapped to a managed handler but the .
NET Extensibility Feature is not installed.
Things you can try:
Ensure that the NTFS permissions for the web.config file are correct
and allow access to the Web server's machine account. Check the ev
ent logs to see if any additional information was logged. Verify the p
ermissions for the DLL. Install the .NET Extensibility feature if th
e request is mapped to a managed handler. Create a tracing rule to tra
ck failed requests for this HTTP status code. For more information about creatin
g a tracing rule for failed requests, click here.
Please help!
I got it working by settings up a new django project from the azure gallery and changed some configs and such.
Edit: The configs I updated was just the name of my app. In my case I also updated the database config with the database I wanted to use in settings.py.
The lesson learned from this is that it is easier to initialize the app from Azure's "Create from gallery" feature, and then pull down the source and modify it via ftp or git to achieve the desired project structure/naming.

HTTP 404 error while invoking a local webservice in .NET MVC4

I am trying to learn webservices in .NET mvc4. I tried creating a new Internet application and adding a Web service (asmx) to the project.
By default, the VS adds a "HelloWorld" Webservice. When I try to run it in the browser, I do get the list of operations, service description(WSDL) and the details of the HellowWorld operation. However, when I try invoking the webservice, it gives the following error :
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.
I might be missing some basic step/setting I guess. Could some body help please. Thanks.
I got the answer from one of my colleagues :) .
When we invoke the service, the MVC tries to resolve the path as specified in RegisterRoutes.
Hence it tries to find a controller with that name and a method with the name same as that of the operation inside that controller. The resolution, ignore the paths with .asmx extension. You can do that by adding the following line in RouteConfig.cs :
routes.IgnoreRoute("{*x}", new { x = #".*\.asmx(/.*)?" });
and it worked. Thanks.

recieving error The file you are attempting to save or retrieve has been blocked from this Web site by the server administrators.<nativehr>0x800401e6

After building and deploying, checked the solution management from Central administration and it's up, a simple web service method that only created a Document Library list with a few columns when trying to retrieve the wsdl or even just by calling the WS fromt the adress since its a void method I recieve some error:
The file you are attempting to save or retrieve has been blocked from this Web site by the server administrators.<nativehr>0x800401e6</nativehr><nativestack></nativestack>
The very same method runs fine when called from another web service project that is already deployed so there's nothing wrong with the code. I'm most probably doing something wrong but can't figure.
The system is running on a win server 2008 with sharepoint 2010, framework 3.5 and "ANY" cpu mode.
thank you!
[edit]
Managed to get rid of the previous error by removing asmx extention from the blocked file list in central administration now instead I'm recieving a 404 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: /_layouts1/my2claims/tt_claims.asmx
it must run under the same application pool as SharePoint