moving website to new hosting causes "forbidden" - asp.net

I am moving website from one hosting server to another hosting server. I have uploaded files. I am using forms authentification. Basically, I am moving to GoDaddy.
I can access login form directly: www.mysite.com/login.aspx
However, when I open www.mysite.com it shows
Forbidden
You do not have permission to access this document.
What can cause this problem? Which files do not have permissions? Should I modify web.config or anything else?
I am using asp.net version 3.5.

Problem:
IIS has configuration for default document, which is typically default.htm, default.aspx, etc. but not login.aspx. If site has no default document in the root folder and directory browsing feature is disabled you will get the Forbidden message.
Solution:
Either create default document as per default IIS configuration
or change IIS configuration to make login.aspx your default document
To create default document, add a new file, name it as default.htm and copy to the root directory of your site
<html>
<head>
<meta http-equiv="REFRESH" content="0;url=login.aspx">
</head>
<body></body>
</html>
To change IIS configuration, go to your hosting settings panel and find Web Server Settings feature where you could add login.aspx to the list of default documents for your account.

Sounds to me that the default page in IIS is not set. It appears that your default page is Login and the IIS default is Default.

It may be because the IIS is not finding a default start page. Adding default document in IIS is one way. But an other way is adding default document (start page) in web.config file.
Suppose if you want to open login.aspx page when some one opens your website, then add following code in web.config file
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="Login.aspx"/>
</files>
</defaultDocument>
</system.webServer>

Think about the basics of how your web server works.
You have one file root folder (typically named www/ or public_html/ or something else depending on your setup) and you have sub folders and files within the root folder.
Web servers work so that they only allow public access to your "public root folder" and not your server files / language specific folders / system folders etc.
And now think about your error message for a second, it tells you that "You do not have permission to access this document." Which is basically talking about either your default.aspx or index.html or some other form of default/index file which loads when you load your root domain.
This is due to "permission error" on that particular file / dependent files etc, exactly as the error message states. You need to check the access mode of your files and folders, which in unix is done by chmod command, and in windows located in file/folder properties -> security -> Permissions which usually lists within a group of users, ie your public/all user group (if it exists)
You need these settings to give read or execute (exec depending on what type of file it is, if html/aspx than read is sufficient, strictly not write in any case as that allows modification to your files by the public) permissions in order for the web server to serve them to public successfully.
In order to give system specific help, your ASP.NET version is not enough to solve it, your IIS info is also needed as well as your server and file system setup etc

Asp.net is probably not registered on your new server. You can check it my adding an simple html file to your folder and try to browse it. As .net is not registered, the aspx extension is unknown.
You should run aspnet_regiis.exe -ir :
%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -ir
%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -ir

Related

web.config application pool error after moving to new server

I have the following error after move my website from server to another server
I have already checked iis and make sure the app has an application pool and it points to the correct file path
here is a screenshot of my application pool
I even tried to add virtual directory and add application and still not working
Check siteMapFile attribute of sitemap
The possible reason behind the issue is:
When you create a new web application using visual studio.net, it automatically creates the virtual directory and configures it as an application. However, if you manually create the virtual directory and it is not configured as an application, then you will not be able to browse the application and may get the above error. The debug information you get as mentioned above, is applicable to this scenario. To resolve it, Right Click on the virtual directory - select properties and then click on "Create" next to the "Application" Label and the textbox. It will automatically create the "application" using the virtual directory's name. Now the application can be accessed.
When you have sub-directories in your application, you can have a web.config file for the sub-directory. However, there are certain properties that cannot be set in the web.config of the sub-directory such as authentication, session state (you may see that the error message shows the line number where the authentication or session-state is declared in the web.config of the sub-directory). The reason is, these settings cannot be overridden at the sub-directory level unless the sub-directory is also configured as an application (as mentioned in the above point). Mostly we have the practice of adding web.config in the sub-directory if we want to protect access to the sub-directory files (say, the directory is admin and we wish to protect the admin pages from unauthorized users). But actually, this can be achieved in the web.config at the application's root level itself, by specifying the location path tags and authorization.
in your case the site map section causing the issue. try to remove it from the config file.
You could refer this below link:
Nested ASP.NET 'application' within IIS inheriting parent config values?

how to allow user download file over web page on window server 2003

I have a webpage deployment on iis6, window server 2003, and i want to allow user can download some file from webpage
I store this file on the backup folder. I added NETWORK SERVICE user to the folder but I still can not download this file
Simple, i have a file and i want user can download this by link: http://www.aitapgdtrh.edu/Backup/SaoLuu13112012_1435.bak
it's shown the error:
The page cannot be found
HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)
Please help me config to download it, Thanks!
I found the answer for my question:
It's:
Open IIS, right click, choose Properties.
At group MIME type, click News,
Add:
Extension: .bak
MIME type: data/sql
then it's ok :)
HTTP 404 means that IIS cannot find the file specified by /Backup/SaoLuu13112012_1435.bak. I assume this is because it's located at C:\Backup and not in inetpub.
Request URLs are relative to the website root path, so /Backup/SaoLuu13112012_1435.bak will refer to C:\inetpub\wwwroot\aitapgdtrh.edu\Backup\SaoLuu13112012_1435.bak not C:\Backup\SaoLuu13112012_1435.bak.
You can reference locations outside of your website root path by using a virtual directory1:
Open IIS
Browse to your website
Right click the root node
Click "New Virtual Directory"
Specify "Backup" as the Alias
Specify "C:\Backup" as Path
Assign read permissions only
Save the directory
1You're allowing read access to the entire Backup directory to anonymous clients by doing this. For security, you may want to require authentication (either NTLM or Forms).
The easiest way is just write an ASP.Net script that uses System.Web.UI.WebControls FileUpload:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx

error for work iis and visual studio

i install visual studio 2010,but i forgot to install iis before it,so now when i want to run asp.net programs,it gives me this error:
virtual directory not being configured as an application in iis,what should i do now?
i see something in another site that said:
Right Click on the virtual directory - select properties and then click on "Create" next to the "Application" Label and the textbox. It will automatically create the "application" using the virtual directory's name. Now the application can be accessed. 2. When you have sub-directories in your application, you can have web.config file for the sub-directory. However, there are certain properties which cannot be set in the web.config of the sub-directory such as authentication, session state (you may see that the error message shows the line number where the authentication or sessionstate is declared in the web.config of the sub-directory). The reason is, these settings cannot be overridden at the sub-directory level unless the sub-directory is also configured as an application (as mentioned in the above point). Mostly we have the practice of adding web.config in the sub-directory if we want to protect access to the sub-directory files (say, the directory is admin and we wish to protect the admin pages from unathorized users).
i do this,but it doesn t work

The requested page cannot be accessed because the related configuration data for the page is invalid

I am getting this error when I try to run an ASP.NET application without a web.config file.
The requested page cannot be accessed because the related configuration data for the page is invalid
as I read, we can run .NET applications without web config files, but when I tried it is giving me the error. I am using iis 7 on windows 7 machine.
When I create the application virtual directory inside inetpub/wwwroot it works fine. Why doesn't the other directory location?
One reason could be the version of .NET framework (on IIS or application pool level) is different from the application one.
Another reason could be if there are modules used in your web.config which the current configuration of IIS doesn't recognize. E.g. URL rewrite or other optional modules, which you have to explicitly enable before using.
This can be a reason:
If there is no Web.config file in the
UNC directory, IIS 7.0 uses the rules
that are defined for the parent
directory. For the Web content to be
served in this scenario, the
worker-process identity must have
access to the whole content directory.
Otherwise, the Web request is
rejected.
Details here.
You need to set permission for your Website folder or copy them to wwwroot folder.
If you choose to set permission, there are two ways:
Right click on Your Website folder, or
Right click to Your Website in IIS
Then select Edit permission and Add a permission (IUSR - default iis user)

Do I need a web config file to run an asp.net hello world on IIS 7?

I have uploaded a simple hello world on my IIS server 7 (shared hosting). It doesn't work. Is it necessary to add a web config and what's the minimum in that case ?
Thanks.
Error says:
Server Application Unavailable
The web application you are attempting
to access on this web server is
currently unavailable. Please hit the
"Refresh" button in your web browser
to retry your request.
Here's the script, very basic :)
<%# Page Language="VB" %>
<html>
<head>
<title>ASP.NET Hello World</title>
</head>
<body bgcolor="#FFFFFF">
<p><%= "Hello World!" %></p>
</body>
</html>
A individual, site-specific web.config is not required to be present in order to get a basic "Hello World" site up and running in IIS7, however, it's rather unusual not to have one.
IIS7, unlike previous versions, effectively has the ASP.NET worker process component "built-in". This allows web.config files to specify configuration of not only your ASP.NET site itself, but also how the IIS server hosting your site should be configured (i.e. you can specify (for example) the default document type in an ASP.NET web.config file).
If you don't specify an individual web.config for your ASP.NET site, the IIS7 server will use the "default" web.config, which is usually located in your "windows" folder within the system-wide configuration of the .NET framework itself.
This article:
Working With Configuration Files in IIS 7
from the MSDN library states:
Configuration Files
Configuration exists in a physical
directory in either server-level
configuration files or in Web.config
files. Every configuration file maps
to a specific site, application, or
virtual directory.
Server-level configuration is stored
in the following configuration files:
Machine.config. This file is located in
%windir%\Microsoft.NET\Framework\framework_version\CONFIG.
Root Web.config for the .NET Framework. This file is located in
%windir%\Microsoft.NET\Framework\framework_version\CONFIG.
ApplicationHost.config. This file is located in
%windir%\system32\inetsrv\config.
Site, application, and virtual and
physical directory configuration can
be stored in one of the following
locations:
A server-level configuration file. When configuration for a site,
application, directory, or URL is
stored in a server-level configuration
file, you must use a location tag to
specify the site, application,
directory, or URL to which the
configuration applies.
A parent-level Web.config file. When configuration for an application,
directory, or URL is stored in a
parent-level configuration file, you
must use a location tag to specify the
child at which the configuration
applies.
The Web.config file for the site, the application, or the directory.
When you configure settings for an
application, directory, or URL, the
configuration is stored in the same
directory as the site, application, or
directory. You do not need to use
location tags.
Storing configuration settings in a
parent configuration file is helpful
when:
You want to store configuration settings in a configuration file that
is accessible by only certain users or
groups. For example, the
ApplicationHost.config file is
available only to the Administrator
account and to the members of the
Administrators group on a specific
computer, as well as to domain
administrators when a computer is part
of a domain.
You want to configure a feature at the URL-level (also known as
file-level).
Also, see the following article for further information:
The new Configuration System in IIS 7
EDIT:
Regarding the specific error message that you're getting, I've seen this before on an IIS7 server, and the problem turned out to be the Application Pool that the site was set to use wasn't "running". Going into the IIS7 admin gui and starting the Application Pool cured the problem.
I have also seen this error caused wen the relevant permissions have not been set on the folder containing your website code.
See here, here, and here for further information.
Of course, since you're testing a shared hosting environment, you probably don't have access to the web server itself, and it's difficult to know exactly what you do have access to, administration-wise, through your hosting provider, but they probably have some kind of interface to set permissions on folders/files, so I'd look there first.
Failing that, you may have to include a web.config file in your "test" site as that will allow you to set configurations within IIS7 that you may otherwise have no access to.
Failing that, you may need to speak to your web host's support team.
It should be enough to inherit from machine.config. What's the exception?
I am not sure about the shared Hosting environment. But If you try to create a web application ( try ASP.Net Empty web application template) and just use Response.write("Hello World !") . it will work without any web.config.
I tried my self and it work successfully.
Only problem is that It may ask you if you wanted to debug your application then it requires to add "compilation = true" attribute in web.config.

Resources