Upload vCard (.vcf) file to IIS7 Site - iis-7

I'm trying to upload a vcard file to a site i've built with ASP.NET. It's hosted on an IIS7 server.
I keep running into the "content type not allowed" error when i try to upload the file. I have write permission to the directory, I've already added the MIME type for vcards and restarted the IIS server, however it still refuses to take it.
I'm using DevExpress UploadControl and i've removed any validation from it so i am fairly certain the control is not restricting the file upload.
Any other suggestions ?

Maybe your component just allow some content types by default and new ones must be granted access manually.
Can you to debug your server side code, to see if your page code executes and to spot exactly what component are throwing up that error?
It's an HTTP error or a .net exception?

Related

Getting "Access to the path is denied" using ASP.net AjaxFileUpload

I have a page using the AjaxFileUpload from the AJAX Control Toolkit. The process works fine on my local machine in Visual Studio. However when I publish it to the server the control is displaying Error after it's uploaded.
Using the Chrome F12 Developer Tools the failed network call is returning Access to the path is denied.
The file is being uploaded to the windows\temp folder, so the issue is when the file is copied from there to the the target uploads directly. The C# code is
AjaxFileUploader.SaveAs(Server.MapPath("~/Uploads/" + e.FileName));
As the developer I don't have access to the server, so I'm speaking to our support to resolve this. I've been told that all the permissions are correct (?).
Is there something in my code that's the issue? If not, what specific permissions that could be missing that I can suggest be checked/changed?
Thanks,
Kevin
I would check to ensure the NetworkService on the server has READ/WRITE permissions to the appropriate folders. Also, as good measure, check to insure the application pool your using has the same access as well.

ASP.NET website on Amazon cloud

I have a asp.net web application. I need to upload the published files to AWS and get accessing it through a browser. I have downloaded S3 browser and and created my account using the access key and secret access key. Then i uploaded the published files to the desired bucket. But when i accessed Default.aspx, browser showed error :
This page contains the following errors:
error on line 1 at column 2: StartTag: invalid element name
Below is a rendering of the page up to the first error.
I just checked uploading a sample html page to that path and i could access it successfully. Is there any thing that I need to do on EC2 to get my website up??
See this answer:
It appears as if the browser tries to display what it thinks is an XML
file, since it gives an error on the second character of the first
line. So I think the file is not parsed, but simply returned as is
immediately. Check if your IIS server is configured correctly and that
it actually parses your ASP tags before returning the page.
You might have a configuration issue in IIS. Try re-registering ASP.Net with IIS on your server using the following from the command-line:
aspnet_regiis.exe -i
The exe file is located under the appropriate framework version on the server in the following directory:
C:\WINDOWS\Microsoft.NET\Framework
Also make sure the version of aspnet_regiis you use is the same as your application's app pool framework version in IIS.

ASP.Net pages don't load on IIS 8

I'm doing application testing on Windows Server 2012 to check compatibility of our web apps (in .Net 4) and am having issues loading any ASPX page. I have tried uninstalling and reinstalling all of the .Net, IIS and ASP.Net roles from Server Manager numerous times. I also found that aspnet_regiis no longer works in Server 2012, it just gives a message to use the role/feature pages instead. I'm at a loss, has anyone else tried IIS 8 yet?
I get the following message:
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
Most likely causes:
•It is possible that a handler mapping is missing. By default, the static file handler processes all content.
•The feature you are trying to use may not be installed.
•The appropriate MIME map is not enabled for the Web site or application. (Warning: Do not create a MIME map for content that users should not download, such as .ASPX pages or .config files.)
•If ASP.NET is not installed.
Things you can try:
•In system.webServer/handlers: ◦Ensure that the expected handler for the current page is mapped.
◦Pay extra attention to preconditions (for example, runtimeVersion, pipelineMode, bitness) and compare them to the settings for your application pool.
◦Pay extra attention to typographical errors in the expected handler line.
•Please verify that the feature you are trying to use is installed.
• Verify that the MIME map is enabled or add the MIME map for the Web site using the command-line tool appcmd.exe.
1.To set a MIME type, use the following syntax: %SystemRoot%\windows\system32\inetsrv\appcmd set config /section:staticContent /+[fileExtension='string',mimeType='string']
2.The variable fileExtension string is the file name extension and the variable mimeType string is the file type description.
3.For example, to add a MIME map for a file which has the extension ".xyz": appcmd set config /section:staticContent /+[fileExtension='.xyz',mimeType='text/plain']
Warning: Ensure that this MIME mapping is needed for your Web server before adding it to the list. Configuration files such as .CONFIG or dynamic scripting pages such as .ASP or .ASPX, should not be downloaded directly and should always be processed through a handler. Other files such as database files or those used to store configuration, like .XML or .MDF, are sometimes used to store configuration information. Determine if clients can download these file types before enabling them.
•Install ASP.NET.
•Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here.
Detailed Error Information:
Module
StaticFileModule
Notification
ExecuteRequestHandler
Handler
StaticFile
Error Code
0x80070032
Requested URL
http://localhost:80/login.aspx
Physical Path
C:\Inetpub\WEBSITE\login.aspx
Logon Method
Anonymous
Logon User
Anonymous
Well, after fighting this issue for the last few days I reset the VM to the base snapshot that I took immediately after finishing the OS install. I followed the exact same steps that I documented during my first runthrough to install the IIS and App Development features then installed my apps and now it works. I have no idea why or how it worked this time where it didn't before, but at least it is working now.

ASMX web service debugging

How can i turn on debugging when trying to add a service to my VB.net app? How can i change the settings to view it remotely? I tried loading up the .asmx page in IE on that server where the file is being hosted and it just asked me to save the file-would never open it to view as a page.
That is the error i get when i try to load the .asmx file from my server.
If you copy that customerrors tag and paste it into the web config file exactly as shown, you'll get the same error screen, but it will show you a detailed error message, which should help you track down the underlying problem.

Forcing custom 404 pages for pages in URL Routing

Coding Platform ASP.NET 4.0 WebForms on IIS7.5
If I request a page blahblah.aspx which does not exist, I get navigated to my custom error page for Page not found Exception. I have implemented URL routing and so I have omitted all my .aspx extensions for routes.
Now, If I type www.mysite.com/blahblah (thats a url without extension) instead of going to my custom error page, it gets redirected to my IIS 404 error page.
What should I do to make my custom error page appear on my site instead of IIS error page?
The Easy Way
If your IIS 7 web server doesn't already have it, install the IIS 7.0 Administration Pack from Microsoft.
Navigate to the root web server name in IIS, and open the Configuration Editor (part of the Administration Pack). Change the dropdown to system.webServer/httpErrors, right-click on defaultPath, and choose 'defaultPath' Attribute -> Unlock Attribute.
Then try to change the custom error handler page again. Navigate to your site, open Error Pages under the IIS group, click Edit Feature Settings on the right, select Custom error pages and finally, put in your path for the default page.
No lock error this time.
I originally tried to unlock this attribute at the web site level but was prevented, so be aware you may have to go all the way to the root of the IIS tree, the web server itself.
The Manual Way
I know you can accomplish all this by direct editing in notepad of the appropriate config file on the web server. And that may be required for your particular web hosting environment or company production web server change protocols. But why make it complicated if it doesn't need to be? Plus, this way you can do it in the GUI, and compare the before and after to see what changes you truly have to make. But if you MUST do it manually, then:
Open the file %windir%\System32\inetsrv\config\applicationHost.config in Notepad. Run Notepad as administrator if you're having problems.
Pro tip: Do not use notepad++ to edit applicationHost.config. You'll end up secretly and silently saving a 32-bit copy of the file that's in a different folder than the one IIS looks in (due to Windows, not np++) without actually affecting the file you wish to change.
You'll see something like this:
<httpErrors lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath">
Remove the ,defaultPath section and save.
You will be able to make the changes you need.
Assuming you haven't done this already...
Go to IIS, select your website, and choose the option "Error Pages". In there, find the 404 status code, right click and go to "Edit Feature Settings". you can then select "Custom Error pages" and change the "Path Type" to URL "Execute URL" to do some rewriting, or a default redirect page for anything else. Put in your URL as a relative value, and now it should redirect to this url on 404 errors.
Edit: Did a bit of digging, in cases, this config may be locked, if you run the following command, it should remove the lock:
%windir%\System32\inetsrv\appcmd unlock config -section:system.webserver/httperrors
Once that is done, you can edit the url properly.

Resources