Multiple websites inside asp .net website - asp.net

Hi I am creating an application where user wants to create and upload multiple websites inside asp .net website.
like
www.mywebsite.com/Websites/Website1
www.mywebsite.com/Websites/Website2
www.mywebsite.com/Websites/Website3
www.mywebsite.com/Websites/Website4
If I upload static website(No database connectivity) to Website1,Website2,Website3 folder it is working fine but If upload website have database in App_Data folder and connection string in web.config folder it is giving me error like : It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Does anyone knows how to solve this issue???
Thanks.

For this Just add virtual directory and put web.config and aspnet_client in that folder and then browse virtual directory..

Thanks all for your suggestions and comments... Few more requirements added to project and goal changed... Now How I am doing (Thought it would be helpful for someone else):
1) Now I am using single Master page for my main website and for multiple websites.
2) Now using single web.config for all the websites(main as well as sub-websites). Because as I have mentioned in my question... static websites are working fine but only problem in database driven websites.
I am not sure that this is the best practice(Who cares when you have no choice :p) but .. It has solved my problem
Last but not Least Thanks #Douglas Thomas and #Shirish ... I have tried this convert to application method on my local IIS and it worked perfectly but now as I have accomplished by other way ... I do not need to contact hosting company [ Some times they made me Angry ] every single time I upload new sub website.

Related

ASP.NET Virtual Path Maps To Another Application Which Is Not Allowed

I have a website that was building without any issue on multiple servers.
But, when I copy/move it on the same machine from one folder to another folder: I started getting the error
The Virtual Path Maps To Another Application Which Is Not Allowed.
What am I doing wrong?
The source of this problem is that when one copies an ASP.NET Web Site to a new folder -- the properties setting associated with the solution "Virtual Path" is set to the folder name and not the root. The solution is to change the Virtual Path setting from the folder name to "/".
This can be found by right click the project and opening the properties dialog: Solution->Properties->Virtual Path-> Change to "/"
This isn't why your error happened but it may be useful to someone researching the problem who ends up here.
If your web app is running as an application within another IIS site (set via the IIS administration tool) and is attempting to reach resources of the other site by means such as HttpResponse.Redirect, make sure the project isn't set to use a separate IIS in Visual Studio. If it is, it may be firing up inside a different IIS than the rest of the site.
Additional check: Missing global.asax also causes the same error.
If you are creating a new HttpContext and calling any external
service, it also causes the same error.
Key is you should not create new HttpContext, change the existing
context to your needs.

MOSS 2010 virtual path to ASP.NET

I am attempting to host an ASP.NET application inside of my SharePoint site. I want to host a full-application so I'm hoping to run it as a virtual path application.
Following instructions mentioned in other areas around the web, which said that I could go into ISS and create a virtual path inside of my SharePoint site to run the application.
Link (page 4)
After finishing this portion I began getting asked for credentials. I got rid of the credentials request, by browsing to the folder containing my Virtual Path and changing security settings to allow iUSR_ account. I no longer get credentials, but I now get a blank page.
I don't know how to get passed this blank page issue, any help is greatly appreciated.
Background: I realize that I can run an application in the layouts folder, but it doesn't seem to work the same as it references .cs files that should be in the code-behind.
-Update-
The blank page issue is solved if I convert the virtual path to an application. However, it seems that I can't piggy-back off of the SharePoint's user credentials when it's an application.
Have you checked that the AppPool for the MVC site is running as the same user as the sharepoint webapp?

Getting 404 error in IIS when calling asp page

I have a problem with my asp.net 4.0 application. When I call it on the server, it works, but when I call it from outside the server, it gives me a 404 error.
The link I call the asp.net application from is the good one. Other asp.net 4.0 applications are working fine when called from outside the server. The other applications are in another folder though, but I do not see why it would work under a folder and not another one. There is no IP restrictions on the applications.
Anyone got that error int eh past?
Thanks
EDIT:
The app is configured as an asp.net 4.0 application. it is stored in a virtual directory.
This link works:
http://localhost/Phonebook/PhoneBook/default-defaut.aspx
this link does not : https://www.test.com/Phonebook/PhoneBook/default-defaut.aspx
A coworker and me found the answer. It's because the server I called on my url was supposed to have a rule redirecting the browser to the right url. So IIS7 on my test server was setted up right.
Theres several things to check.
That test.com is even going to your server. Put a file in the root directory 'test.txt' that IIS lists as the root folder for your site. ensure you can get to it.
Once you verify your root site folder WORKS for ex., www.test.com/test.txt then ensure you have a virtual directory /phonebook that contains a folder phonebook within it.
Seems overkill to be having to folders named phonebook. Try taking one of them out and pointing your web application to your
c:\whatever\phonebook\phonebook folder.
Make sure port 443 is bound to your app if you're using https, that could be your problem.

ASP.NET site inside a virtual directory

I am currently putting a new version of my site online. I would like to retain the old site (for purposes of read only access) and have been directed to place it within a subfolder inside the directory where the site use to live. e.g.
www.example.com needs to be moved to www.example.com/old and the new site needs to be moved to www.example.com
Unfortunately I get the classic ASP.NET error when attempting to piggy back sites that each have their own web config.
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.
How can I compeletly seperate off the new site and access it via. www.example.com/old without ASP.NET trying to trickle down through my directories and find the main sites web.config?
Thanks!
Giving the site its own AppPool should work.
You can do this by creating an AppPool and then on the virtual directory in IIS setting the app pool to your new one in the properties.
Make sure that the virtual directory is an application and not just a virtual directory.
You may try the following setting in the site contained in the virtual dir:
<location inheritInChildApplications="false">
Rick Strahl has the same problem and describes his experiences on his blog.
Didn't try it out myself, but found other blog articles which use it successfully with IIS6.
I've tried both creating a new App Pool on the site. That's didn't work -- same errors. I also added the inheritChildApplications attribute directive in my web.config. That didn't work either. The only way I have been able to achieve what I needed was to add a new subdomain in an entirely new folder and put a redirect to it in my www.example.com/old page to old.example.com.
It's not what I was looking to do, but it solved the issue.

ASP.NET MVC - Website paths

I am using a 3rd party component which creates settings files based on hard-coded file paths i.e. they are compiled into the DLL e.g.
%APPDATA%\Vendor\Settings.ini
I have created a few console/service applications that use this and work very well. However, I am now trying to use a similar approach via my ASP.NET MVC web application and the settings file never seems to write out!
Usually if the application is running under my acconut for example the file would be written to somewhere like:
C:\Documents and Settings\James\Application Data\Vendor\Settings.ini
So I thought if the website AppPool was running under the same account the file would be saved to the same place....However, it never appears. The account is an admin account running under Windows server 2003.
Any ideas?
Thanks.
Have you checked to see if the settings file is created in the App_Data folder in the web application? If not, could you put an existing settings file there and see if it uses it?
It's not about the webpool account, it's about guest user's account.
Go to the properties of your site in IIS, Directory Security and in the anonymous access click on the Edit button, there you'll see wich account is been used when someone access your site.
Couldn't find a solution to this, so I decided to develop a local WCF service (which would create the settings file in the correct directory path) and just accessed it via my web application.

Resources