web-config

Leverage browser caching with web.config in .net?

最后都变了- 提交于 2020-01-12 14:12:51
问题 Some of sites are on shared hosting (Windows 2003 Server), so I have no way to access server configuration. I read everywhere about leverage browser caching, expecially for static files (jpg, css, js, etc.) but... how to do this in my case? The hosting has .NET installed, could a web.config file help in some way? If yes, how? 回答1: Here is how I did on my site that is on a shared host. I believe the cacheControlMaxAge is as follows days:hours:minutes:seconds but dont quote me. <system

Integration Test Web Api With [Authorize]

。_饼干妹妹 提交于 2020-01-12 05:45:08
问题 So I've found bits and pieces that have enlightened me some on the [Authorize] tag, but nothing that solves my problem. My scenario is that I have Web Api methods that I want to hit with integration tests using RestSharp. However RestSharp is getting my login page, instead of the results of the call. [Authorize] public Item GetItem([FromBody] int id) { return service.GetItem(id); } The product uses a custom login system, and what I would REALLY like would be a way to disable the [Authorize]

Deny all files in a directory, via web.config setting

杀马特。学长 韩版系。学妹 提交于 2020-01-12 05:29:27
问题 As a test, I'm trying to use the web.config to control security in the following ways: Deny access to all files in a directory, except for a specific file Allow access to all files in a directory, except for a specific file So I set up the web.config as follows: <?xml version="1.0" encoding="utf-8"?> <configuration> <!-- Deny access to all files in a directory, except for a specific file --> <location path="NonAccessibleDirectory"> <system.web> <authorization> <deny users="?"/> <deny users="*

Remove “Server” header from ASP.NET Core 2.1 application

巧了我就是萌 提交于 2020-01-12 04:37:07
问题 Is it possible to remove the Server Response header in a ASP.NET Core 2.1 application (running on Server 2016 with IIS 10)? I tried putting the following in the web.config: <system.webServer> <httpProtocol> <customHeaders> <add name="X-Frame-Options" value="sameorigin" /> <add name="X-XSS-Protection" value="1; mode=block" /> <add name="X-Content-Type-Options" value="nosniff" /> <remove name="X-Powered-By" /> <remove name="Server" /> </customHeaders> </httpProtocol> </sytem.webServer> The

WebForms and ASP.NET MVC co-existence

心不动则不痛 提交于 2020-01-11 09:16:18
问题 I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I've done to make that happen is that I added a namespaces node to the WebForms web.config : <pages styleSheetTheme="Default"> ... <namespaces> <add namespace="System.Web.Mvc"/> <add namespace="System.Web.Mvc.Ajax"/> <add namespace="System.Web.Mvc.Html"/> <add namespace="System.Web.Routing"/> </namespaces> </pages> However, when I try to start the project, I get an error stating: " Compiler Error

C# namespaces in web.config

坚强是说给别人听的谎言 提交于 2020-01-11 08:56:11
问题 Coming from a VB background and being forced to learn C# I have hit the first hurdle. In VB i could put all the namespaces I wanted available across the entire app in the web.config file and it would be available in each code behind file without me having to add import statements. <namespaces> <clear/> <add namespace="System"/> <add namespace="System.Collections"/> <add namespace="System.Collections.Generic"/> It seems Visual Studio can't do this with C# and I have to add using statements all

How to connect to Oracle DB from .NET?

大兔子大兔子 提交于 2020-01-11 08:34:07
问题 When I open SQL Command Line, I write CONNECT username/password@[//]host[:port][/service_name] and it connects me to the database just fine. However, I'm unable to connect from a .NET project using a connection string. I have tried many things such as <add name="ConnectionString" connectionString="Data Source=username/password@[//]host[:port][/service_name];" /> and <add name="ConnectionString" connectionString="server=tcp:host;Initial Catalog=service_name; user id=username; password=password

ASP.NET hostingEnvironment / shadowCopyBinAssemblies

末鹿安然 提交于 2020-01-11 05:22:06
问题 Today I stumpled upon the shadowCopyBinAssemblies option in the hostingEnvironment tag. Appearently this attribute it is a web.config (system.web) configuration Boolean option indicating whether the assemblies of an application in the Bin directory are shadow copied to the application's ASP.NET Temporary Files directory. <hostingEnvironment shadowCopyBinAssemblies="false" /> A colleague had to enable this setting because (only) on his development machine he frequently got that ASP.NET error

The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced

夙愿已清 提交于 2020-01-11 02:10:51
问题 The Problem Error when going to a specific page (in local debug): CS0012: The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Here are the referenced lines of code in the error message: Line 28: Line 29: Line 30: public class _Page_Views_blah_granny_cshtml : System.Web.Mvc.WebViewPage { Line 31: Line 32: #line hidden All other pages

Change Microsoft Config File Encryption Method From TripleDES

自古美人都是妖i 提交于 2020-01-10 20:06:30
问题 When encrypting ("protecting") Microsoft config sections, you get something that looks like the XML below. It follows (at least partially) the W3 spec for XML Encryption. However, in the XML below you'll see that the EncryptionMethod under the EncryptedData section is "tripledes-cbc". We would like to be able to change that to a more-secure alternative, specifically AES, which is specified in the aforementioned W3 spec as well. In many calls with Microsoft's support engineers, they are