So, I have an application that needs multiple Webconfigs. I seperated each Web form in its own folder and put a web config file.
How do I make sure that Login Webform only uses the LoginWeb.Config?
This is my root Web Config and that is what it's using.
I've done searches, and the closest thing I came too was this in my LoginWeb.config file
<appSettings>
<add key="theme" value="Login theme"/>
</appSettings>
No idea how to link that to my Login.aspx web form so it can use that specific config file. Help would be appreciated.
Related
I published a json file on to my website using ftp. When I tried to access my site using mtsite.com/abc.json it throws the below error.
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
My file is on hosted site on azure. Even if file in on server why did it say that file is not found?
Any place in azure portal where I can add or allow Mime type json? I cannot add web.config file as My files are all HTML and Json.
By default IIS (and so the Azure App Service) doesn't serve .json files. You need to enable this feature in your web.config. If don't already have one, create it in the root directory.
Open your web.config and place this code
<staticContent>
<remove fileExtension=".json"/>
<mimeMap fileExtension=".json" mimeType="application/json"/>
</staticContent>
under the nodes
<configuration>
<system.webServer>
And it should be fixed.
Here you can find a basic web.config template that i've made a while ago
P.S: Even though you are using only HTML and JSON, this is the only way to go (as there is not a UI solution in the portal). In this way you could also control other aspect of your website, for example the redirect to HTTPS for the HTTP requests.
I have the following HTML in my Azure Web Application:
Please complete and return the
Terms of Service
The .csproj file does have this pdf included in it:
When I click "Launch Google Chrome" to test locally in Visual Studio and when I click on "Terms of Service", I get the following error:
But the file is there! It is on my file system. There is no encoding necessary. Why is this error shown and why can't the PDF be downloaded from the web app? Do I need another step to publish it? Please help!
By default, contents of Views folders are not supposed to be accessed by the normal request pipeline. The Views folder is home for the view files (.cshtml) which will be executed by the view engine. If you look at the web.config file located inside ~/Views you can see that we have a BlockViewHandler registered which prevents direct file access to all files.
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode"
type="System.Web.HttpNotFoundHandler" />
</handlers>
You should consider moving your pdf file to a Statics directory in the app root and point to that.
Now, point to that location
Terms of Service
You can give your own name for the directory. Some people like to keep it under the Content directory. So it is more of a personal preference.
In asp.net core, the wwwroot directory is the static content home by default. So you may keep your static contents inside that (this is overridable)
You could make changes to the web.config located in the views directory to allow direct browsing, but the more solid approach is to not pollute the convention and move the static assets to it's own folder. If you absolutely want to enable direct file access to the view directory, you can update the path attribute value to tell mvc to prevent access to only files with a specific extension. Here is how you will prevent only .cshtml files ( so pdf will work)
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*.cshtml" verb="*" preCondition="integratedMode"
type="System.Web.HttpNotFoundHandler" />
</handlers>
i created a website using asp.net visual studio 2010 express
today i purchased a hosting program with plesk 11.
on the welcome email of the hosting services i got this line: "please be sure that your homepage is saved as an "index" file e.g., index.htm, index.html, etc
all my website is .aspx files!
also my homepage is using a master page!
they help support couldn't help me.
so i ask you can i just rename it to index.aspx and upload it as it is?
Open your web.config file and set the following property in it.
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="Path of your Page" />
</files>
</defaultDocument>
</system.webServer>
Hi I just installed Apache Tomcat 7 and got the server running OK. When I entered localhost:8089 (8089 being the port I assigned to Tomcat 7) the apache website popped up and I got to run some jsp examples and they opened correctly.
However now I wish to create a jsp file myself (I am trying tutorials for the very first time) and when I open them, only the source code I written is showing in the browser.
The example I am trying is this:
<html>
<head>
</head>
<body>
Hello World. <%= new java.util.Date() %>
</body>
</html>
and all I'm seeing in Chrome is : "Hello World. <%= new java.util.Date() %>"
I am saving this file in this path:
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\host-manager\WEB-INF\jsp
In WEB-INF there is an index.html file ready.
Am I doing something wrong? Where am I supposed to save my file?
I tried watching tutorials on youtube but most of them were in arabic and I couldn't understand a thing!
Thanks in advance for any help!
Your JSP file must NOT be in WEB-INF.
You must create a directory named as you want (myFirstWebApp for example), put your JSP in any subdirectory you want except WEB-INF (for example myFirstWebApp/foo/bar/hello.jsp), then deploy the webapp by copying the myFirstWebApp firectory to the webapps directory of Tomcat. The JSP will then be accessible using the URL
http://localhost:8089/myFirstWebApp/foo/bar/hello.jsp
WEB-INF is where you put the files that you don't want to make accessible from the outside:
the jars (under WEB-INF/lib),
the classes (under WEB-INF/classes),
the deployment descriptor (web.xml, optional in servlet 3.0 webapps configured through annotations),
and any other file you want anywhere under WEB-INF (typically, configuration files).
Why don't you read the documentation? http://tomcat.apache.org/tomcat-7.0-doc/appdev/deployment.html
Rename your jsp-file to:
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT\index.jsp
now, navigate to
http://localhost:8089/
Short and Easy.
Put your jsp file in ROOT folder as
/Users/<username>/Desktop/tomcat/webapps/ROOT/test.jsp
Run your application like
http://localhost:8080/test.jsp
Save your jsp file in your webapps directory with .jsp extention
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps
and types at the address bar of the browser- http:\localhost:8089/exmp.jsp
and press Enter key
My first Azure website is a simple test site I've had for a while that makes ajax calls back to the server for JSON data. All the data files have .json extensions. Azure will not 'see' these files. If I change the extension to .txt it servers them up fine.
Do I have to muck with IIS to get this .json to be seen?
I too found Ahmed Sabbour's blog post helpful, but it created an additional problem for me. Whilst the fix worked for the Azure Web App when I then tried to run the app locally it died horribly, throwing HTTP 500.19 everywhere. It took me a while to figure out how to fix this whilst maintaining a single web.config. The solution was (albeit a bit of a fudge) to remove the fileExtension first and then add it back in:
<staticContent>
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
For my narrow purposes this was fine and I hope this might save someone time trying to figure this out.
Citing Ahmed Sabbour with his blog post http://blogs.msdn.com/b/africaapps/archive/2013/06/07/how-to-serve-static-json-files-from-a-windows-azure-website.aspx you have to do the following:
"If you upload a .json file to your Windows Azure website and try to access it, it would give you a 404 File Not Found error, because the MIME Type of .json is not set by default. This also applies in general to any file that might need a specific MIME Type.
To fix this issue, FTP into your website and upload the following Web.config file which will set the correct MIME types. If you already have a Web.config file in place, just add the below to the appropriate section.
<?xml version="1.0"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
". I did this and the 404 was gone.
It appears that Azure (Cloud Services, at least) knows how to serve JSON from a deployed ASP.NET MVC project. The problem in my case was that the Build Action on the JSON file's property page was not set correctly. Changing the Build Action to Content fixed it for me.
have you tried adding the specific MIME type to your server's config file?
http://www.iis.net/configreference/system.webserver/staticcontent/mimemap
If you add the mime type as
application/json; charset=utf
that should work.