What is the difference between configuring a Caching Profile in Web.Config and configuring it in IIS?
If you have this in Web.Config
<caching>
<outputCache enableOutputCache="true" />
<outputCacheSettings>
<outputCacheProfiles>
<add duration="14800" enabled="true" varyByParam="*"
name="AssetCacheProfile" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
And nothing configured in IIS in the Output Caching, will it work?
And what if you add all the extensions I use in Output Caching in IIS, what does that change?
It's a aspx page RetrieveBlob.aspx that uses this Caching Profile:
<%# OutputCache CacheProfile="AssetCacheProfile" %>
<%# Page Language="C#" AutoEventWireup="true" CodeFile="RetrieveBlob.aspx.cs"
Inherits="RetrieveBlob" %>
Related
This is the default.aspx file
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"Inherits="Default"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Welcome to sample website:)
</div>
</form>
</body>
</html>
This is the web.config file
<?xml version="1.0"?>
<configuration>
<system.web>
<authentication mode="Windows"/>
<identity impersonate="true"/>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
I am unable to get the windows authentication , I did the required changes in the applicationhost.config file as well.Kindly help me how to proceed ahead.
Your web.config configuration is incomplete.
See: Enabling Windows Authentication within an Intranet ASP.NET Web application
There's also plenty other guides/blog posts on setting up Windows Authentication for asp.net if you just search the internet.
You haven't told ASP.NET to deny anonymous users, which is why you don't get the login prompt.
<configuration>
<system.web>
<authentication mode="Windows" />
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</configuration>
Note that the directive within the
section above is what tells ASP.NET to deny access to the application
to all “anonymous” users to the site (the “?” character means
anonymous user). This forces Windows to authenticate the user, and
ensures that the username is always available from code on the server.
I got project that runs on main ftp directory copy all the files to new directory in the ftp with name "new"
And now i have a problem its no reconized the master page in all the aspx files because the path is
~/templ.master
And if i change it to
~/new/templ.master
Its working good but i have a lot of files and codebehind (vb files) too that not reconized
So i ask for a way to change the main website directory on my project
That the project will take all the files from new dir...
How to do it?
Tnx a lot
edit:
again thats my files:
new/templ.Master
new/templ.Master.designer.vb
new/templ.Master.vb
new/default.aspx
in new/templ.Master there is a line like this:
<%# Master Language="VB" AutoEventWireup="false" CodeBehind="templ.master.vb" Inherits="WebApplication1.templ" %>
in new/default.aspx there is a line like this:
<%# Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/templ.Master" CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>
when i change in the default.aspx to line:
<%# Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/new/templ.Master" CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>
its working but its not read the CodeBehind="templ.master.vb" its take the file templ.master.vb from the root not from the new directory...
and like i said i have a lot of aspx files so i cant change all MasterPageFile="~/templ.Master" to MasterPageFile="~/new/templ.Master" ...
i search a short way to do it...
Set the website directory as main folder of the website and change the default mainpage in web.config as below:
Web.config
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="~/templ.master"/>
</files>
</defaultDocument>
</system.webServer>
try to add this to web.config:
<system.webServer>
<rewrite>
<rules>
<rule name="redirect" stopProcessing="true">
<match url="^$" />
<action type="RedirectToSubdir" url="/new" />
</rule>
</rules>
</rewrite>
</system.webServer>
If it doesn't work, do a manual process: Juts replace "MasterPageFile=" with MasterPageFile="~/new/ by hit CTRl+H in visual studio (select Match case and apply that for current project). Do a same thing for CodeBehind=" etc.
I created a web site using VS2010 .NET Framework 4.0
I built the project and published it to the local file system. After uploading all published folders and files to the public_html directory. Whenever I hit on my domain I got following errors
Access forbidden to domainname.com
XML Parsing Error
XML Parsing Error: not well-formed
Location: http://www.example.com/index.aspx
Line Number 1, Column 2:<%# Page Title="My Website" Language="vb" AutoEventWireup="false" MasterPageFile="~/MasterHomePage.Master"
-^
My web.config is
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<customErrors defaultRedirect="" />
<compilation strict="false" explicit="true" targetFramework="4.0" />
</system.web>
<system.net>
<mailSettings>
<smtp from="">
<network host="" password="" userName="" />
</smtp>
</mailSettings>
</system.net>
<system.webServer>
<directoryBrowse enabled="true" showFlags="None" />
<defaultDocument>
<files>
<add value="index.aspx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
What am I doing wrong?
I don't see any option on godaddy linux hosting cPanel to configure asp.net
One more question I heard that I cannot host asp.net website on linux hosting. Is it true?
Website hosts like godaddy are not able to support asp.net sites on a linux machine. If, however, you have your own linux server (dedicated or virtual) you may have success using mono though there are a number of limitations
Supported Versions
Mono supports ASP.NET 2.0, ASP.NET AJAX and a handful of 3.5 controls.
Limitations
Mono’s ASP.NET does not implement the following features:
Precompiled updatable web sites.
WebParts APIs.
I have a web.config file in the root folder of my ASP.NET Web Application that registers all user controls in my project.
~/web.config
~/Controls/MyReusableControl.ascx
~/Non/Reusable/Controls/AnotherControl.ascx
~/Non/Reusable/Even/More/Specific/Controls/MyThirdControl.ascx
<system.web>
<pages>
<controls>
<add tagPrefix="uc" tagName="MyReusableControl" src="~/Controls/MyReusableControl.ascx" />
<add tagPrefix="uc" tagName="AnotherControl" src="~/Non/Reusable/Controls/AnotherControl.ascx" />
<add tagPrefix="uc" tagName="MyThirdControl" src="~/Non/Reusable/Even/More/Specific/Controls/MyThirdControl.ascx" />
</controls>
</pages>
</system.web>
Registering every control in the root web.config file seems like a bad idea. Most of my controls are designed specifically for a single page or a group of related pages.
I'd like to register my non-reusable controls in a web.config file that is logically closer to the page where the controls are actually used.
~/Controls/MyControl.ascx
~/web.config
<system.web>
<pages>
<controls>
<add tagPrefix="uc" tagName="MyReusableControl" src="~/Controls/MyReusableControl.ascx" />
</controls>
</pages>
</system.web>
~/Non/Reusable/Controls/AnotherControl.ascx
~/Non/Reusable/web.config
<system.web>
<pages>
<controls>
<add tagPrefix="uc" tagName="AnotherControl" src="~/Non/Reusable/Controls/AnotherControl.ascx" />
</controls>
</pages>
</system.web>
~/Non/Reusable/Even/More/Specific/Controls/MyThirdControl.ascx
~/Non/Reusable/Even/More/Specific/web.config
<system.web>
<pages>
<controls>
<add tagPrefix="uc" tagName="MyThirdControl" src="~/Non/Reusable/Even/More/Specific/Controls/MyThirdControl.ascx" />
</controls>
</pages>
</system.web>
Am I allowed to do that? I tried simply moving the relevant parts of the configuration to the new web.config files, but that seems to break the web forms designer for pages that reference the non-reusable controls.
Element 'AnotherControl' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.
Obviously, my web.config files are all there. What's interesting is that my project does compile and my web pages do show my user controls. It's just Visual Studio designers that crash with the above error.
I'm using Visual Studios' built-in ASP.NET Development Server (VWD) to test my web site during development.
I would like this ASP.NET web site to use extensionless URLs (pages don't require the aspx extension). Ordinarily I would configure a custom 404 in IIS that directs to an ASPX page. How would I do this with VWD?
P.S. This is not an ASP.NET MVC web site.
Here is an example of a Web.Config using UrlRewritingNet. Doing this will allow you to do extensionless Rewriting without having to write any HttpModule or anything like that.
(full article here)
Note: this requires IIS7 as it is using the system.webServer section of the web.config.
<configSections>
<section name="urlrewritingnet"
restartOnExternalChanges="true"
requirePermission="false"
type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter" />
</configSections>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />
</modules>
</system.webServer>
<urlrewritingnet rewriteOnlyVirtualUrls="true"
contextItemsPrefix="QueryString"
xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
<rewrites>
<!--Enable HTM(L) Extensions-->
<add name="pageHTML"
virtualUrl="^~/(.+).htm(.*)"
redirectMode="Permanent"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/$1.aspx"
ignoreCase="true" />
<!--Fix the WebResource JS Error-->
<add name="WebResourceFix"
virtualUrl="^~/WebResource.axd(.*)"
rewriteUrlParameter="IncludeQueryStringForRewrite"
destinationUrl="~/WebResource.axd$1"
ignoreCase="true"/>
<!--Fix the ScriptResource JS Error-->
<add name="ScriptResource"
virtualUrl="^~/ScriptResource.axd(.*)"
rewriteUrlParameter="IncludeQueryStringForRewrite"
destinationUrl="~/ScriptResource.axd$1"
ignoreCase="true"/>
<!--Allow Extensionless Page Extensions-->
<add name="pageExtensionless"
virtualUrl="^~/(.+)$"
redirectMode="Permanent"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/$1.aspx"
ignoreCase="true" />
</rewrites>
</urlrewritingnet>
There's nothing special you need to do. Just remove the .aspx extension from the ASPX page file and it should work fine with VWD. The Visual Studio designer will probably complain that there's no build provider registered for the extension '', but you can just ignore it. Then you can reference the page without extension:
http://localhost:2181/Default
<%# Page Language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Hello World
</div>
</form>
</body>
</html>
If you are trying to get something like http://localhost:3000/value to go to http://localhost:3000/page.aspx?tag=value then you can use an HttpModule, which is also a good alternative to a 404 redirect. I used to do the same thing too.
I posted some example code in a previous question.
All you need to do is add the module in two different places within your web.config...
<system.web>
<pages theme="Default" />
<httpModules>
<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />
</httpModules>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRewriteModule"/>
<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />
</modules>
</system.webServer>
The first one is to add it to your httpModules with will work in your VS Dev environment, and the second one will for IIS7