asp.net
Any way to clear/flush/remove OutputCache?
You can use the VaryByCustom parameter for this. In your user control you would have the following: <%@ OutputCache Duration=”1000″ VaryByParam=”None” VaryByCustom=”MyKey” %> Then you would override the GetVaryByCustomString method in your Global.asax like so: public override string GetVaryByCustomString(HttpContext context, string arg) { if (arg == “MyKey”) { object o = context.Current.Application[“MyGuid”]; if (o == … Read more
MSCharts “No http handler was found for request type ‘GET'” error
This is what you need for ASP.NET 4.0 / IIS 7.5 on Windows 7: Your web.config must contain the following: <appSettings> <add key=”ChartImageHandler” value=”storage=file;timeout=20;” /> </appSettings> <compilation targetFramework=”4.0″> <assemblies> <add assembly=”System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″/> </assemblies> </compilation> <system.webServer> <handlers> <add name=”ChartImg” verb=”*” path=”ChartImg.axd” type=”System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ /> </handlers> </system.webServer> You also need this at … Read more
How can I make a TextBox control that is multiline not be resizable?
You should be able to disable textarea resizing in Chrome and Safari with this css: textarea { resize: none; }
How do I allow multiple roles to see a page when using a custom RoleProvider in ASP.Net
you can add the PrinicpalPermission attribute multiple times. [PrincipalPermission(SecurityAction.Demand, Role=”Admin”)] [PrincipalPermission(SecurityAction.Demand, Role=”AnotherRole”)]
IIS AAR – URL Rewrite for reverse proxy – how to send HTTP_HOST
This post has the answer – Modifying headers with IIS7 Application Request Routing Need to enable preserveHostHeader – can’t see how you do that in the UI but this works Run this from command line to update Machine/webroot/apphost config %windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/proxy -preserveHostHeader:true /commit:apphost
SelectedValue which is invalid because it does not exist in the list of items
Apparently the solution I posted wasn’t entirely effective… Eventually in my application I changed to this: listOrgs.Items.Clear(); listOrgs.SelectedIndex = -1; listOrgs.SelectedValue = null; listOrgs.ClearSelection(); // Clears the selection to avoid the exception (only one of these should be enough but in my application I needed all..) listOrgs.DataSource = new Organization().DTListAll(SiteID); listOrgs.DataTextField = “OrganizationName”; listOrgs.DataValueField = … Read more
ASP.NET cookie expiration time is always 1/1/0001 12:00 AM
The problem here doesn’t really lie with ASP.NET but with the amount of information that is provided in the http request by browsers. The expiry date would be unobtainable regardless of the platform you are using on the server side. As you have summarised yourself in your question the Expires property of the HttpCookie object … Read more
web application exists on both the local IIS web server and the IIS Express web server
Try deleteing applicationhost.config or move it to a different folder, worked for me. In my case the problem was that the project was set up to start on IIS local by another developer.
Web API Queryable – how to apply AutoMapper?
Use the AutoMapper’s Queryable Extensions. First, define the mapping. // Old AutoMapper API // Mapper.CreateMap<Person, PersonDto>(); // Current AutoMapper API Mapper.Initialize(cfg => cfg.CreateMap<Person, PersonDto>() ); Then you can use something like this: [EnableQuery] public IQueryable<PersonDto> Get() { // Old AutoMapper API // return this.dbContext.Persons.Project().To<PersonDto>(); // New AutoMapper API return this.dbContext.Persons.ProjectTo<PersonDto>(); } Edit 04/2019: Updated to … Read more