How to restrict the file which is in the folder of my web application project which is built using vb.net and hosted in windows server 2008? - asp.net

How to restrict the file which is in the folder of my web application project which is built using vb.net?When the url of the web application is used to traverse the file ,it is able to access the file but the folder is restricted..I have the url as "https://firstwebsite.com/js/js.js".When this is run,it displays the script in the file(js.js). When https://firstwebsite.com/js/ is run,it shows the forbidden error.I need to restrict the file also and to show the forbidden error.I have disabled the directory browsing also and tried with many,but couldn't restrict.Server is windows 2008.
I don't have any .php pages but including all the security in web config file but i couldnot redirect the file requested also.I tried to place the script also.Can you please tell me how to redirect the url when https://firstwebsite.com/js/js.js is accessed?
I have a js file say "js.js" in my website.
say my website is "firstwebsite.com" and the js file is in a directory "js"
I want to prevent direct url access to the "js.js" file i.e. if anyone types the url "firstwebsite.com/js/js.js" ,then the js file should not be executed and it should return a error message(403.1 forbidden error or redirect to another page) instead.

Related

404 when trying to access web api

I have an application I'm deploying to azure.
It's a SPA app which uses REST API.
I placed the folder of the app in side the wwwroot folder.
when I try to access the API from my local machine i.e. my localhost:1979/api/auth/login
I can do it but after I place the files in the www folder - I get a 404
when trying to access:
domain.com/api/auth/login
I tried doing it on my machine on my local IIS and got the same error.
I'm sure it's a stupid thing like configuration but I can't figure it out.
Thanks for any help
Solved
Ok.
So I checked the issue on my local IIS and got the same problem.
The thing is, I created a directory inside an existing solution which have the web api + mvc.net and called the directory which contains the html i.e. mydomain.com/dist/index.html directly.
The solution was to send the html file via the controller so when a user comes in to the site, the home controller will send the html file and the ajax call from the JS file which was download from the html will succeed unlike getting the html directly.

HTTP Error 401.3 - Unauthorized for accessing file on UNC

I have a ASP.NET website set up IIS7.5 on Server1. The website has a virtual directory uploads where physical path is \\Server2\UploadFolder.
The website URL is http://Server1:8080/Default.aspx.
When I hit the above URL I can upload file through page and the file gets uploaded to the virtual directory. Lets say I upload file uploadedfile.jpg.
Now When I hit http://Server1:8080/uploads/uploadedfile.jpg ideally the browser should able to get the file in response instead the browser shows error.
HTTP Error 401.3 - Unauthorized
You do not have permission to view this directory or page because of the access control list (ACL) configuration or encryption settings for this resource on the Web server.
I have given access to IUSR and NETWORKSERVICE on folder \\Server2\UploadFolder still no help.
Am I missing anything? Any help appreciated.
I think, you need to map the Drive for \Server2\UploadFolder this folder
Could you please try Link 1 and Link 2? it may help you.

Where does IIS look for files

Can anyone explain, please, exactly how .net works. I create a web site in Visual Studio and publish it to a local server to a folder at
D:\WebSites\Project1
I create a web site in IIS and provide the address of the folder containing the files for the web site. When I publish the site, using 'fixed naming and single page assemblies', all the .aspx files go in the folder on the D drive and a dll for each page goes in the bin folder inside that folder.
I would assume that when someone wants to view a page in their browser, IIS retrieves the file(s) required from the folder specified, they get processed and turned into html and sent to the browser.
Recently when someone clicked a button on a page that calls a web service - a file not found error was reported. Apparently
C:\Temp\bx5tn2js.dll
could not be found. The thing is - why did IIS decide to look in C:\Temp for a file?
And, in the error message was a load of references to xml serialization. What is being serialized?
This file looks like the compile files that asp.net generates on compile.
This folder can be setup on web.config on compilation session with the
tempDirectory="C:\Temp"
If you do not have set this option asp.net is use a default folder that is usually inside the asp.net directory, inside the windows folder. But if you have set this, and this folder did not have the correct permissions, then asp.net fails to compile the project, and you can get a message like that.

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

Giving 404 error in web site ? Asp.net?

In web application, i created a site and place the code in my domain [using filezilla i upload the my pages in my domain ]. i place my folder which contain the code in domain like
BusinessEntity Folder, BusinessLayer Folder, DataAccess Layer and my code Folder. my web.config is my code folder. but when i type my url it is giving 404 error. Can you help me to solve this problem. Thank you.
404 - Not Found error. Some resource can't be obtained. Open Fiddler or any other web debugger and check what request return 404 error. After that check existing a resource corresponding to Url
Please check all these things are done properly
Publish the project from your local machine (using visual studio)
Upload the published project to the server.
Create a virtual directory in iis (in the server)
Map the virtual directory to the project folder (means select the physical directory as the project folder)
Do the necessary configuration changes (conection strings or appsettings)
Give write permission for the upload folder and error folder (If you use any)
Checkout http://www.advancedinstaller.com/user-guide/tutorial-iis.html

Resources