I need my css to show for my login page, but it's not showing at the moment. How would I go about allowing access to my login page with the css included? Im using forms authentication, and my code block for my web.config file looks as such:
<authentication mode="Forms">
<forms loginUrl="UserAccount/Login" defaultUrl="UserAccount/Index" timeout="60"></forms>
</authentication>
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>
My site.css is in my /Content/Site.css path. How do I add it to allow access to this file to all users?
the <deny users="?"/> denies anonymous users from accessing the css file. (read here)
so you'll need to put the following into your <configuration> block within web.config
<location path="Content">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
you can read some more about this here
I work this out by the followings steps:
IIS Manager
Authentication
Right Click Anonymous Authentication.
Switch to application pool identity
Stumbled across this, cause I needed the same thing. Here is a solution:
<location path="Content">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
As is writer here (I used the link from the previous answer) this will give the unauthenticated user access to all the files in the Content folder, and the css file is in this folder.
P.S. sorry guys, this is the same as the previous answer, just ignore this
Related
I'm having an issue with cache in my webpage.
My webpage is hosted by GoDaddy, with the Economic Windows Server with Plesk.
conexaomktdigital.com.br
It's a very simple site, I DONT USE PHP on it, only HTML, CSS and simple bootstrap JS.
When I run PageSpeed Insights, the results are telling me to optimize browser cache, including adding expire dates to my .css and images.
Mobile: 60/100
Desktop: 75/100
HOW I DO IT? I seek everywhere and don't see anything, everybody talks about .htaccess, but it's not apache, it's windows with plesk by GoDaddy... What should I do, can someone help me?
Create and use a correct 'Web.Config' file. put it in your root folder.
You can find some information about how to use a web.config file with te right tags here:
https://www.giftofspeed.com/leverage-browser-caching/
I use a very simple configuration, it appears to work nice for me:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
<caching enabled="true" enableKernelCache="true">
<profiles>
<add extension=".html" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange"/>
<add extension=".css" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange"/>
<add extension=".js" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange"/>
<add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange"/>
<add extension=".png" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange"/>
</profiles>
</caching>
</system.webServer>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>
</configuration>
this will keep the files listed there in cache until it have some change.
No Error 500 for me, I think it will not happen to you too.
I've been working on a ASP.NET web application project in Visual Studio. In that project, when the user enters the hostname they get a 404 error but what I would like to happen is for them to be redirected to the index.html when they have just entered the hostname.
Below is the code that I tried using but it didn't work. It said there were too many redirects which I think has something to do with the path value being empty
<location path="">
<system.webServer>
<httpRedirect enabled="true" destination="index.html" httpResponseStatus="Permanent" />
</system.webServer>
</location>
Does anyone have an suggestions?
If you are using MVC you could create a default route but since you asked for a way to do it in web.config try:
<configuration>
<system.web>
<customErrors defaultRedirect="index.html" mode="On">
<error statusCode="404" redirect="index.html"/>
</customErrors>
</system.web>
</configuration>
I have a website inside which I have a directory I want to keep private. My login page is inside this directory called admin.aspx.
In my main Web.Config I have the following block:
<authentication mode="Forms">
<forms loginUrl="~/Account/admin.aspx" name=".ASPXFORMSAUTH"></forms>
</authentication>
And then in my subdirectory I have a second web.config file with the following:
<location path="admin.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
However when I try to get to admin.aspx I get this error:
The web page at http://localhost:51167/Account/Login?ReturnUrl=%2FAccount%2FLogin%3FReturnUrl%3D%252FAccount%252FLogin%253FReturnUrl%253D%25252FAccount%25252FLogin%25253FReturnUrl%25253D%2525252FAccount%2525252FLogin%2525253FReturnUrl%2525253D%252525252FAccount%252525252FLogin%252525253FReturnUrl%252525253D%25252525252FAccount%25252525252FLogin%25252525253FReturnUrl%25252525253D%2525252525252FAccount%2525252525252FLogin%2525252525253FReturnUrl%2525252525253D%252525252525252FAccount%252525252525252FLogin%252525252525253FReturnUrl%252525252525253D%25252525252525252FAccount%25252525252525252FLogin%25252525252525253FReturnUrl%25252525252525253D%2525252525252525252FAccount%2525252525252525252FLogin%2525252525252525253FReturnUrl%2525252525252525253D%252525252525252525252FAccount%252525252525252525252FLogin%252525252525252525253FReturnUrl%252525252525252525253D%25252525252525252525252FAccount%25252525252525252525252FLogin%25252525252525252525253FReturnUrl%25252525252525252525253D%2525252525252525252525252FAccount%2525252525252525252525252FLogin%2525252525252525252525253FReturnUrl%2525252525252525252525253D%252525252525252525252525252FAccount%252525252525252525252525252FLogin%252525252525252525252525253FReturnUrl%252525252525252525252525253D%25252525252525252525252525252FAccount%25252525252525252525252525252FLogin%25252525252525252525252525253FReturnUrl%25252525252525252525252525253D%2525252525252525252525252525252FAccount%2525252525252525252525252525252FLogin%2525252525252525252525252525253FReturnUrl%2525252525252525252525252525253D%252525252525252525252525252525252FAccount%252525252525252525252525252525252FLogin%252525252525252525252525252525253FReturnUrl%252525252525252525252525252525253D%25252525252525252525252525252525252FAccount%25252525252525252525252525252525252Fadmin%25252525252525252525252525252525253FReturnUrl%25252525252525252525252525252525253D%2525252525252525252525252525252525252fAccount%2525252525252525252525252525252525252fadmin has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.
I don't understand why it's got itself in a loop. If I change web.config (inside the directory) to simply say:
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
I can get to it so is it something with the location option?
Thanks.
Razor is nicely working under it's own api url
<location path="api">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
</httpHandlers>
</system.web>
</location>
but when SqlMembershipProvider authorization is added like so
<location path="api">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
</httpHandlers>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
The api/urls are redirected to the regular web forms login page as expected but never successfully redirects back after a correct user/pass is entered. The same login page works fine with the legacy .net .aspx locations in the app.
How do I configure SqlMembershipProvider to be run before my .cshtml pages so the User identity can be accessed via RequestContext.HttpContext.User as described in other articles?
Currently if I am hosting an Access .MDB file to allow users to download, IIS7 is throwing a 404 error. I know the file is there and the permissions are fine. It appears to be a Handler issue, but I cannot figure out how to change the handler to allow downloading of MDB file. I assume I need to add something to the Handlers section of the web.config, but I am unsure of the syntax.
Thanks.
Or, if you don't want to modify a system-wide configuration file, you could add the following lines to that section in your web.config:
<remove fileExtension=".mdb" />
<add fileExtension=".mdb" allowed="true"/>
For example your Web.config should be similar to this:
<configuration>
<system.webServer>
<security>
<requestFiltering>
<fileExtensions allowUnlisted="true" >
<remove fileExtension=".mdb" />
<add fileExtension=".mdb" allowed="true"/>
</fileExtensions>
</requestFiltering>
</security>
</system.webServer>
</configuration>
Also see http://www.adamwlewis.com/articles/iis-7-not-serving-files-4047-error.
OK, found it.
Just need to remove the following line:
<add fileExtension=".mdb" allowed="false" />
in the "requestFiltering" section from the \Windows\System32\inetserv\config\applicationHost.config file.