system.web

HttpContext not available in Class Library

你说的曾经没有我的故事 提交于 2019-12-01 02:10:47
I am working on a project where I have a C# class library which needs to use the System.web.HttpContext . I've done this before in another project without problem but now its not working. I'm not sure what I am missing they're both targeting .net 3.5 and I've added the reference System.web and added the directive using System.web . However, when I try and do HttpContext nothing is found. I've tried using the full path System.web.HttpContext but the only thing that comes up are 3 items related to ASP. Below are screenshots from the working project intellisense and the non-working intellisense

Using MimeMapping in ASP.NET 5 (vNext)

岁酱吖の 提交于 2019-11-30 08:07:54
I'm trying to move my old mvc5 project to mvc6. Old code was: public string ContentType { get { if (!string.IsNullOrEmpty(FileName)) return MimeMapping.GetMimeMapping(FileName); return null; } } Error is The name 'MimeMapping' does not exist in the current context The following code should work: string contentType; new FileExtensionContentTypeProvider().TryGetContentType(FileName, out contentType); return contentType ?? "application/octet-stream"; There is a NuGet package MimeTypes which works with .Net Core projects as an alternative to FileExtensionContentTypeProvider . I'm not aware of any

Alternative to HttpUtility.ParseQueryString without System.Web dependency? [duplicate]

吃可爱长大的小学妹 提交于 2019-11-29 11:32:00
问题 This question already has an answer here: How to parse a query string into a NameValueCollection in .NET 18 answers I want to be able to build URL query strings by just adding the key and value to some helper class and have it return this as a URL query. I know this can be done, like so: var queryBuilder= HttpUtility.ParseQueryString("http://baseurl.com/?"); queryBuilder.Add("Key", "Value"); string url = queryBuilder.ToString(); Which is exactly the behaviour I'm after. However, this class

Cannot add System.Web.dll reference

岁酱吖の 提交于 2019-11-28 19:06:06
I'm trying to use the HTTP functions contained in the System.Web.dll assembly. However, whilst the dll seems to exist in the same directory as every other dll Visual Studio 2010 references in my project, it fails to link in and raises a warning - "The referenced component 'System.Web' could not be found". The dll, however, is definitely there within the same folder as all others referenced by the project and selecting it in 'browse for reference' mode allows me to add it - it then fails to fill in the 'Path' property. Am I doing something wrong? How can I make System.Web available in my

What is the use for IHttpHandler.IsReusable?

北战南征 提交于 2019-11-28 04:48:04
I'm writing a IHttpHandler and I'll need to implement a IsReusable property. When I look at the MSDN documentation it says: Gets a value indicating whether another request can use the IHttpHandler instance. This isn't very helpful. In which situations should I use a reusable handler and in which situations should it not be reusable? Follow up questions: What is reuse? Can I maintain state (i.e. class variables) when Reusable = true ?? This property indicates if multiple requests can be processed with the same IHttpHandler instance. By default at the end of a request pipeline all http handlers

.NET Framework 4 Client Profile + System.Web.dll?

可紊 提交于 2019-11-27 07:40:25
问题 I'm currently developing an application for .NET 4 Client Profile, as this is the version that will be present on most home computers through Windows Update. However, I cannot add a reference to System.Web.dll as it does not exist in this version - what should I do? Is it a good idea to deploy System.Web.dll along with my application, or won't that work? I really need HTTP connections and all, so I cannot modify my application as a workaround. Is targeting my application to .NET 4 (no client