I am trying to deploy my test website to the ftp server, yet I am having quite a few difficulties with it (as it is my very first time doing this).
Here is how the ftp's server folder setup looks like:
There is a main folder named www_root, which contains the following two folders app_data and data.
Here is a printscreen from a TotalCommander:
I was being told by the support people, that I need to copy all my data into the www_root folder.
Once I published my ASP.NET 5 MVC application via Visual Studio 2015 to a File System, I could see three folders:
My base index.html, together with css & javascript is located under wwwroot folder. Here is what the inside of wwwroot folder looks like:
When I copy the contents of my wwwroot folder inside www_root folder (under FTP) and I exclude web.config file, then my base webpage is loaded without a problem (but without server side logic...it's just a plain page with some HTML & CSS code).
Now the problem occured when I added web.config to that folder, then suddenly I received Error 500 when I tried to open my website. I believed that the problem was caused by the fact that web.config contained the following setup:
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="..\approot\web.cmd" arguments="" stdoutLogEnabled="false" stdoutLogFile="..\logs\stdout.log" startupTimeLimit="3600"></httpPlatform>
</system.webServer>
</configuration>
Here I could see that we are targeting \approot\web.cmd file. Therefore what I did was, that I copied my approot & logs folders (generated by Visual Studio) to the base folder under my FTP.
So in the end when I logged in to my FTP I had the following folders: approot, logs, www_root, where inside of www_root I had all my css, js, & index.html.
Nonetheless, when I reloaded my webpage, it still gave me the 403 - Forbidden: Access is denied..
How can I solve this problem? What am I doing wrong?
In the end, the problem was occurred by the fact, that my hosting server had folder named www_root, however my ASP.NET application automatically creates folder wwwrooot.
What I ended up doing is creating a script, which loops through all the files and replaces wwwroot with www_root.
That has solved the problem.
Related
I have built an ASP.NET Core Web API in Visual Studio 2017 using the Web API template. When I test it during development it runs using IIS Express and works as expected. The index.html file is served from the wwwroot folder, makes some AJAX requests to the ASP.NET server which makes some HTTP requests to a third party API to obtain some data which is eventually returned to the browser. No datbase involved. I tried to publish to IIS so that another person at my company can use it locally on their machine (which will have IIS running). I published through Visual Studio 2017's publisher:
Right click on project and publish to IIS (following directions from this tutorial: https://learn.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/deploying-to-iis)
When I publish, a web page opens with the URL I put as the destination URL:
localhost/ProjectName
but I get this error: HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
There is not config error identified on that screen.
Here's what my web.config looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule"
resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\StandardsGenerator.dll"
stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
<!--ProjectGuid: 78162755-cd01-4a5c-8863-1087bd7f6f8f-->
Is there something wrong with this configuration? If anyone can point to resources that describe what should be in a web.config file that may be helpful.
Also, when I publish the app and navigate to localhost/ProjectName I expect an index.html file to be served from the wwwroot directory. In my test environment I configured this in my LaunchSettings.json. Where do I configure the start page for a published app?
Regarding 500.19 errors, there are multiple reasons why you could encounter this error. To troubleshoot this further, please enable detailed errors for this application from IIS. To do so, launch IIS, select the specific website. Open Error pages section in the center panel. Right click on the page and select "Edit Feature Settings". Choose "Detailed errors" here. You can also follow this blog which speaks on the same lines - https://blogs.msdn.microsoft.com/rakkimk/2007/05/25/iis7-how-to-enable-the-detailed-error-messages-for-the-website-while-browsed-from-for-the-client-browsers/
Reproduce the issue and share the error message here. IIS generally gives out which module/configuration needs tweaking.
To answer your second question regarding start page, Select the website, click on "Default Document" and add the "index.html" page here and move it to top. This way, whenever the user accesses your website, he will see the index.html first.
Is there a way to tell IIS to read configurations from a different file than web.config?
Why would anyone do this?
Convenience. When working with static resources like an .aspx, or .js, or an MVC view file, it is often sufficient to hit Refresh in the browser to see the effect of that change.
Also, more specific to our scenario is that we re-use some of our code-base in different flavors of the web site, their differences being defined in their respective .config files, and each of these sites run locally on our development clients.
Getting the change to a different location than the one you are actually working in is somewhat time-consuming: A Publish operation will properly compile and copy the entire web application to the target location, copying the individually changed file manually is often... fiddly.
So what I would like for to be possible is this:
I work on my project in c:\workbench\FlavMaster3000. In this folder I create the various flavors of web.config files:
web.apple.config
web.banana.config
web.cherry.config
I create sites in IIS that represents each flavour and set their directory to the same as above.
https://local-apple/
https://local-banana/
https://local-cherry/
And I would like for IIS to read each site's configurations from the respective flavor of .config.
Is this at all possible, or am I a dreamer with a hopeless dream?
-S
You can put your specific configuration in external file(s) and link those files in your web.config file as shown below. However downside is way web.config is watched for any changes in it and gets applied immediately when you save web.config, these external files will not be monitored and you will require to manually restart app pool.
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings configSource="Myconfigs/myappSettings.config"/>
<connectionStrings configSource="Myconfigs/myconnections.config"/>
<system.web>
<pages configSource="Myconfigs/mypages.config"/>
<profile configSource="Myconfigs/myprofile.config"/>
<httpHandlers configSource="Myconfigs/myhttpHandlers.config"/>
<httpModules configSource="Myconfigs/myhttpModules.config"/>
</system.web>
</configuration>
I am using Visual Web Developer 2010 Express (I am using VS for 10 years) and I publish a web site using web publish to Azure. I want to publish a generic file lets say a .dat file that users will download. How should I add it to project so that it is published and available to download by users. I tried adding to specific folder in project, setting build to content and always copy. I can see the folder created but when I type specific URL , i got generic file or folder not found error. If I put an xml file to same folder , I can see it with direct url.
Internet Information Service does not serve the files that it does not know about. Your .dat file is not supported by IIS by default so you have to add it manually.
Add following configuration to your web.config file.
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".dat" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>
I need to prevent someone from directly accessing a pdf, instead only allowing them to be pulled through the app itself. How can this be done?
Add this to your top-level Web.config to block a folder called Reports (your folder name goes there).
This will allow your application to access Reports/file.pdf but an outside request to yoursite.com/Reports/file.pdf will be blocked.
<configuration>
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="Reports" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>
There are two solutions for doing that:
1- You can put your “UsersUploads” folder outside the website
directory, so if your website exist on “c:\website\example.com” you
can put the “UsersUploads” there “c:\UsersUploads”, Like that IIS has
no control over this folder and its files, And your website code will
still have access to this directory as a normal physical path.
2- Stop IIS from serving this folder:
IIS by default doesn’t server some website folders and files such
App_Data, App_Code, bin, App_GlobalResourses, App_LocalResources,
Web.config,….
Put the files in the app_data folder and then use a HttpHandler to serve the files. You can use url rewriting if you want to hide it and make it look cleaner.
set the permissions on the folder to deny access to whoever. Ask your sys admin guy to create an account and give read access to the folder. Then set impersonation up in the web.config file to use the new account.
Read this
http://msdn.microsoft.com/en-us/library/aa292118(VS.71).aspx
hey guys,
i have downloaded mondor's captcha control, and implemented on localhost, thats working fine, but when i did the same steps and uploaded to the hosting server, i am unabel to get captcha image,i want to know whats the difference between placing dll's in bin folder and adding it as a reference because anyway it will go in bin folder. on localhost i added a reference to that dll and on hosting server i just added the dll in the bin folder, is that the problem, if yes than what could be the solution for this issue...
If anyone knows about it, please suggest..
Please check IIS version on server.
For IIS 7
change the following line in web.config file under <system.webServer> <handlers>:
<add name="MSCaptcha" path="CaptchaImage.axd" verb="GET" type="MSCaptcha.CaptchaImageHandler, MSCaptcha" preCondition="integratedMode,runtimeVersionv2.0"/>
Check all folders and files had been uploaded related to captcha control