IIS and asp.net appcmd - c#

HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
Most likely causes:
A default document is not configured for the requested URL, and directory browsing is not enabled on the server.
Things you can try:
If you do not want to enable directory browsing, ensure that a default document is configured and that the file exists.
Enable directory browsing.
Go to the IIS Express install directory.
Run appcmd set config /section:system.webServer/directoryBrowse /enabled:true to enable directory browsing at the server level.
Run appcmd set config ["SITE_NAME"] /section:system.webServer/directoryBrowse /enabled:true to enable directory browsing at the site level.
Verify that the configuration/system.webServer/directoryBrowse#enabled attribute is set to true in the site or application configuration file.
I have the above error when I try to run my first application with VS12. Have you any idea of what is going wrong and how can I fix it ? In VS10 I guess I don't have this sort of error message

You need to enable directory listings and/or add a default document (default.aspx, default.htm...) to the root of the site.
For more information about directory listing: Enable directory listing

Related

Response.Redirect() Works in Visual Studio but not IIS

I'm trying to upload a basic web application from visual studio on Windows 7 to an IIS environment on Windows Server 2007.
Though launching it from IIS displays the Login page, trying to navigate past it to the main menu returns this error:
Server Error in Application "PARKING/PARKING ASSIGNMENTS WEB"Internet Information Services 7.0
Error Summary
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. Detailed Error Information
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL http://localhost:81/Parking Assignments Web/Home
Physical Path C:\ParkingAssignmentsWeb\Home
Logon Method Anonymous
Logon User Anonymous
Most likely causes:
•The directory or file specified does not exist on the Web server.
•The URL contains a typographical error.
•A custom filter or module, such as URLScan, restricts access to the file.
Things you can try:
•Create the content on the Web server.
•Review the browser URL.
•Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click here.
Links and More InformationThis error means that the file or directory does not exist on the server. Create the file or directory and try the request again.
View more information »
This is the code I used for navigation:
Response.Redirect("Home.aspx");
Why would this navigation work on Visual Studio but not on IIS?
UPDATE: I tried the variations of the Redirect command you guys showed me but all of them gave a 404 error, which leads me to believe that the problem isn't with the command but with something else. Any idea what?
It treats Home.aspx as a relative path.
Use it like:
Response.Redirect("/Home.aspx");
when you deploy to IIS a different web server is being used. Visual studio uses a web server with limited options and in most cases but not all an application should run without changes when deployed to IIS on windows server.
Things to check
Verify that the folder structure on your workstation looks the same as the folder structure deployed to the server.
check permissions on the folders accessed by IIS on the web server
Response.Redirect("Home.aspx"); assumes that the file is in the same directory as the page that is invoking the transfer
add a more complete path either ("/home.aspx") or ("/folder/home.aspx") where folder is the actual folder name that contains the .aspx file
Please try:
Response.Redirect("~/Parking Assignments Web/Home.aspx");
or
Response.Redirect("~/Parking Assignments Web/Home");

application redirect to IIS root folder during upload excel file in asp.net

I am facing issue in my web application which is made in asp.net. I have host the application on IIS server.and I am going to upload excel file to port data in database from application.when i uploading from locally from server itself its working fine but i when i try to uploading using public ip or outside then my application redirect to IIS root folder can any one tell me whats is the issue.
this could be an permission issue on your web.config, file and folder permission or maybe a missing reference to correct folder.
Web.config
What is the authentication ? Do you allow Anonymous access. I understand that you can upload fine if you open the side from localhost from the server itself. Did you try to open the side with public ip from the server itself ?
Application Pool in IIS
Look for the "Identify" configuration and set this to "ApplicationPoolIdentify"
File Permission
Look for the folder and ensure that the "IIS_IUSERS" got write permissions
Code Try to sepecify the correct path using the server.MapPath()
Dim myPath As String = Server.MapPath("foldername") & "\" & "filename.csv"

Adding a SQL Filetable folder as a Virtual Directory

Using IIS 7.5 .NET Framework 4. I have a web page that needs to access a SQL 2012 Filetable folder. In IIS, I set up the file table folder as a virtual directory & in the connection, I'm using my active directory account login as the account to "Connect as...". I'm able to access the FileTable folder in windows explorer by going to it's location:
\\computername\sqlexp2012\filetabledb\filetabletb_dir
In IIS, if I right click on the virtual folder, and then click Explore, it opens up a Windows Explorer instance & displays the files there (lots of PDF files).
However, if I try to access the virtual folder directly (http://localhost/virtualfoldername) by right-clicking & going to Manage Virtual Directory, or access it through a web page (http://mywebsite/vname) I get the following error.
Error Summary
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related
configuration data for the page is invalid.
Detailed Error Information
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x80070032
Config Error
Config File
Requested URL http://localhost:80/virtualfoldername
Physical Path \computername\sqlexp2012\FileTableDB\FileTableTb_Dir
Logon Method Not yet determined
Logon User Not yet determined
Config Source
-1:
0:
If I go in to the Virtual Directory & go to Manage Virtual Directory --> Advanced Settings, I see the physical path to the SQL Filetable folder & Physical Path credentials. My user account is set up as dbo under Security --> Users. The IIS log file is not helpful, nor is anything in the Event Viewer.
Anything I've been able to find has said that it is likely permissions related, but using my account - which I know works, as far as accessing the file share via Windows Explorer - doesn't. Any thoughts welcome.
Thanks!

Adding module for .exe file in IIS 6.0

I have problem with configuration for IIS 6.0.
I have a server which is used for download purpose, but for all files I would like to add custom header by a module:
private void Application_EndRequest(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
String filePath = application.Request.Path;
String fileName = VirtualPathUtility.GetFileName(filePath);
application.Response.AddHeader("Content-Disposition", String.Concat("attachment; filename=\"", fileName, "\""));
}
My problem is that when I try to do that for .exe file it doesn't work.
I tried adding under mapping an extension to .exe -> c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll but that only forces to execute the .exe file on server.
I tried also with different execution permissions but setting anything other than Scripts and Executables resturns: HTTP Error 403.1 - Forbidden: Execute access is denied.
Any idea how to force that module to work with .exe files?
Does it allow you to download .exe file without your module?
On web site properties in IIS manager, Home Directory tab, make sure execute permissions is set to "scripts only".
On web site properties in IIS manager, HTTP Headers tab, be sure to define .exe as a valid MIME type.
Be sure to stop and restart the IIS Service (via Services)
Refer to http://blogs.msdn.com/b/david.wang/archive/2005/07/11/allow-file-downloads-on-iis-6.aspx

connectionString encryption

I'm trying to encrypt the connection strings in my web.config. I'm following the instructions from Walkthrough: Creating and Exporting an RSA Key Container. However, when I get to the part with the command:
aspnet_regiis -pe "connectionStrings" -app "/MyApplication" -prov "MyProvider"
it keeps complaining:
"The configuration for the virtual path '/MyApplication' and site 'Default Web Site' cannot be opened
Failed to map the path '/myapplication'
Failed!
I'm fairly sure I've followed the instructions correctly. I created the project named 'MyApplication' directly in the 'C:' root.
Any ideas? Perhaps I should be following a different set of instructions?
Thanks for your answers. Turned out I needed to run the command prompt as "Administrator"
Did you add the MyApplication folder as a virtual directory in IIS under the default web site? That seems to be what it's looking for, not a folder path...
According to this MSDN post, you can use -site to define the site to target. An excerpt from that site:
Use the –app option to identify the application for which the
Web.config file will be encrypted and the -site option to identify
which Web site the application is a part of. The Web site is
identified using the site number from the Internet Information
Services (IIS) metabase. You can retrieve the site number from the
INSTANCE_META_PATH server variable in the ServerVariables collection.
For example, when IIS is installed, a Web site named "Default Web
Site" is created as site 1. In pages served from that site, the
INSTANCE_META_PATH server variable returns "/LM/W3SVC/1". If you do
not specify a -site option, site 1 is used.
/MyApplication is a virtual path and the message seems to indicate that path is not available i.e. there is no http://localhost/MyApplication. Did you forget to create virtual directory for your app in IIS?

Categories

Resources