Questions tagged [asp.net-4.5]
Refers to the version 4.5 of the ASP.NET web application framework introduced with the .NET Framework 4.5
asp.net-4.5
615
questions
180
votes
6
answers
540k
views
IIS_IUSRS and IUSR permissions in IIS8
I've just moved away from IIS6 on Win2003 to IIS8 on Win2012 for hosting ASP.NET applications.
Within one particular folder in my application I need to Create & Delete files. After copying the ...
160
votes
12
answers
177k
views
GlobalConfiguration.Configure() not present after Web API 2 and .NET 4.5.1 migration
I recently started following this guide to migrate my project to .NET 4.5.1 and Web Api 2.
The very first thing MS developer Rick Anderson asks you to do is change:
WebApiConfig.Register(...
93
votes
2
answers
44k
views
Why is my ClaimsIdentity IsAuthenticated always false (for web api Authorize filter)?
In a Web API project I am overriding the normal authentication process to check tokens instead. The code looks something like this:
if ( true ) // validate the token or whatever here
{
var claims ...
91
votes
2
answers
33k
views
Using Grunt, Bower, Gulp, NPM with Visual Studio 2015 for a ASP.NET 4.5 Project
Visual Studio 2015 comes with built in support for tools like Grunt, Bower, Gulp and NPM for ASP.NET 5 projects.
However when I create a ASP.NET 4.5.2 project using Visual Studio 2015 it doesn't use ...
81
votes
6
answers
54k
views
Build ASP.NET 4.5 without Visual Studio on Build Server
Its been a while since I setup a Build Server so maybe I've forgotten something or maybe .NET 4.5 is different from whatever version I did this with last time, but here is my problem.
I'm trying to ...
67
votes
4
answers
48k
views
Unable to declare Interface " async Task<myObject> MyMethod(Object myObj); " [duplicate]
I'm unable to declare
interface IMyInterface
{
async Task<myObject> MyMethod(Object myObj);
}
The compiler tells me:
The modifier async isn't valid for this item
The async modifier can ...
63
votes
1
answer
26k
views
What can I do in C# 5 with .Net 4.5 that I couldn't do in C# 4 with .Net 4? [closed]
I have Visual Studio 2012 RC installed on Windows 8 Release Preview and my question is are there any useful new features not related to Metro, or is Metro what seperates .Net 4 and .Net 4.5?
47
votes
14
answers
27k
views
The "EnsureBindingRedirects" task failed unexpectedly
When I create new ASP.NET 4.5 web forms application from vs2012 and update all nuget packages, I receive this error on build:
Error 1 The "EnsureBindingRedirects" task failed unexpectedly.
...
43
votes
6
answers
15k
views
Writing to ZipArchive using the HttpContext OutputStream
I've been trying to get the "new" ZipArchive included in .NET 4.5 (System.IO.Compression.ZipArchive) to work in a ASP.NET site. But it seems like it doesn't like writing to the stream of HttpContext....
40
votes
1
answer
21k
views
EntityFramework 5 use dll version 4.4.0.instead 5.0
I have project based on .NET 4.0 but I need to use EntityFramework 5 in my solution. So I install it from the NuGet.
After that I change target framework to .NET 4.5 (I'm using VS 2012) and rebuild ...
38
votes
2
answers
23k
views
How to detect IIS Express version?
I have found that our ASP.NET application runs differently on different machines in IIS Express. All have VS 2012, .Net 4.5 and Integrated mode. But some has VS 2012 Update 1, some not.
How do I find ...
38
votes
3
answers
46k
views
Bundling resources via bundle.config vs BundleConfig.cs in ASP.NET 4.5 WebForms
Regarding ASP.NET 4.5's new System.Web.Optimization / Microsoft.AspNet.Web.Optimization:
Can anyone explain the difference in the use of bundling resources using the BundleConfig.cs class file as ...
37
votes
1
answer
17k
views
Using Claim-Based Authorization
The new ASP.NET 4.5 code has "re-parented" the ASP.NET RoleProvider to a ClaimsProvider.
What I'm trying to figure out, is what would a "claims based" example of authorization look ...
34
votes
5
answers
71k
views
User.Identity.IsAuthenticated is false after successful login
I need to get the UserId Guid directly after a successful login. The following code doesn't work:
if (Membership.ValidateUser(txtUsername.Value, txtPassword.Value))
{
FormsAuthentication.SignOut()...
33
votes
4
answers
7k
views
Using ASP.NET 4.5 Bundling & a CDN (eg. CloudFront)
ASP.NET 4.5 has a great new bundling feature and appears to have some support for use of CDNs. The example given by Microsoft for use of the bundling feature with a CDN is this
public static void ...
30
votes
2
answers
22k
views
Understanding context in C# 5 async/await
Am I correct that async/await itself has nothing to do with concurrency/parallelism and is nothing more than continuation-passing style (CPS) implementation? And the real threading is performed by ...
28
votes
1
answer
15k
views
How to use MachineKey.Protect for a cookie?
I want to encrypt the ID that I am using in a cookie. I am using ASP.NET 4.5 so I want to use MachineKey.Protect to do it.
Code
public static string Protect(string text, string purpose)
{
...
26
votes
2
answers
55k
views
requestValidationMode 4.5 vs 2.0
Is there a difference between requestValidationMode="4.5" and requestValidationMode="2.0"? I have a .net 4.5 application, there is a control which I don't want to validate, as users can enter html ...
23
votes
3
answers
18k
views
view code coverage report on azure devops portal
I am running the NUnit tests (project in .Net Framework 4.5), as part of azure devops build pipeline.
- task: VSTest@2
inputs:
testAssemblyVer2: 'tests/**/*.Tests.dll'
...
23
votes
1
answer
15k
views
Unit Testing MVC 4 RedirectToAction
I am trying to unit test the redirection of my controller in MVC 4 .Net 4.5. Here is an example:
[TestMethod]
public void Register_PassValidModel_RedirectToHomeIndexShouldBeTrue()
{
...
22
votes
5
answers
140k
views
Register .NET Framework 4.5 in IIS 7.5
Pieces of the puzzle:
Windows 7
.NET Framework 4.5 (installed)
IIS 7(Version 7.5.7600.16385)
Visual Studio (Ultimate 2013)
MVC4 (multiple projects in the solution)
The solution I'm running in Visual ...
21
votes
2
answers
12k
views
Is MVC4 baked into .NET 4.5?
A lot of release notes for Visual Studio 2012 talk about .NET 4.5 and MVC4, but I can't tell if MVC4 is actually part of the .NET 4.5 release. Anybody know for sure? I would love not to have to ...
20
votes
13
answers
87k
views
Failed to load viewstate. The control tree into which viewstate is being loaded
I am receiving the following error message after an HTTP POST on an ASP.NET form hosted inside a UserControl:
Failed to load viewstate. The control tree into which viewstate is being loaded must ...
20
votes
2
answers
13k
views
Type definition exists in two libraries
I am building an ASP.NET Web Forms web site using .NET 4.5.
The error ...
The type 'System.ComponentModel.DataAnnotations.Schema.ForeignKeyAttribute' exists in both 'f:\Projects\web sites\...
20
votes
1
answer
5k
views
How should I handle exceptions within a controller constructor in WebAPI?
Say I have a constructor where it's initialization can potentially throw an exception due to reasons beyond my control.
FantasticApiController(IAwesomeGenerator awesome,
IBusinessRepository ...
19
votes
3
answers
43k
views
How to implement HttpMessageHandler in Web API?
In an ASP.NET 4.5 MVC 4 Web API project, I want to add a custom HttpMessageHandler. I've changed WebApiConfig class (in \App_Satrt\WebApiConfig.cs), as follows:
public static class WebApiConfig
{
...
18
votes
2
answers
20k
views
ASP.NET MVC 4 Areas in separate projects not working (view not found)
I have tried to create simple proof-of-concept ASP.NET MVC 4 web site using areas in separate projects.
I tried to following tutorials: http://bob.archer.net/content/aspnet-mvc3-areas-separate-...
18
votes
1
answer
22k
views
System.Web.Security.AntiXss.AntiXssEncoder vs Microsoft.Security.Application.AntiXssEncoder
In ASP.NET 4.5 there is a new namespace System.Web.Security.AntiXss which includes encoding routines from version 4.0 of the AntiXssLibrary (http://www.asp.net/aspnet/overview/aspnet-45/whats-new#...
17
votes
1
answer
15k
views
How to use System.Web.Caching in asp.net?
I have a class that looks like this:
using System.Collections.Generic;
using System.Web.Caching;
public static class MyCache
{
private static string cacheKey = "mykey";
public static ...
17
votes
1
answer
3k
views
.NET 4.5 MVC RouteCollection.LowercaseUrls breaks when using Area
A new property to RouteCollection was added with .NET Framework 4.5:
http://msdn.microsoft.com/en-us/library/system.web.routing.routecollection.lowercaseurls.aspx
This works great, until you add an ...
16
votes
5
answers
29k
views
How to disable System.Security.Permissions.ReflectionPermission usage in new VS2013 Asp.net template so it works on shared hosting
I created a brand new Visual Studio 2013 ASp.net MVC application off of the default MVC template. However I am getting an error message Request for the permission of type 'System.Security.Permissions....
15
votes
3
answers
23k
views
Upgrading to ASP.NET 4.5/MVC 4 forms authentication fails
I've just downoaded a VS 2012 along with ASP.NET 4.5 and MVC 4.0 and was kicking the tires with a sample app and found that the forms authentication that works perfectly with ASP.NET 4.0/MVC 3 no ...
15
votes
2
answers
15k
views
The predefined type 'System.Threading.Tasks.Task' is defined in multiple assemblies in the global alias
I just have set up a new asp.net mvc 4 project, using the latest .net framework (4.5) in combination with Visual studio 2012. After I added some classes, side projects etc. I suddently notice that I'm ...
14
votes
2
answers
11k
views
Azure downloadtostreamasync method hangs
here is the offending code
public async static Task<MemoryStream> AsyncReadBlob(string identifier)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageString)...
14
votes
1
answer
5k
views
AspNetSession layout renderer not working
I am using NLog for logging in my asp.net 4.5 website. I have used NLog 4.0. Now I need to use session variables in my logs. So i tries to use AspNetSession layout renderer. This layout renderer is ...
12
votes
6
answers
3k
views
Add color options to System.Drawings.Color
In visual studio, when creating controls in the markup(or in code-behind) you can specify colors in HEX format like this: "#FFFFFF", but you also can select from the list of preset colors like: White, ...
12
votes
5
answers
8k
views
Is it possible to pass a value to the SelectMethod of a Repeater?
ASP.Net 4.5 introduces new ways to bind data to controls like the Repeater through the SelectMethod property:
<asp:Repeater runat="server" ItemType="MyData.Reference"
SelectMethod="...
11
votes
2
answers
12k
views
HttpRuntime.Cache Equivalent for asp.net 5, MVC 6
So I've just moved from ASP.Net 4 to ASP.Net 5. Im at the moment trying to change a project so that it works in the new ASP.Net but of course there is going to be a load of errors.
Does anyone know ...
11
votes
1
answer
6k
views
How to use OpenID providers with unique identifier URLs in ASP.NET MVC4
The new SimpleMembershipProvider implemented in ASP.NET MVC4 allows easy, built-in support for two popular OpenID providers (Google and Yahoo) and three OAuth providers (Microsoft, Facebook, Twitter). ...
11
votes
1
answer
3k
views
Strongly typed data binding and generics?
Suppose I want to bind a generic type (here: Dictionary<string, string>) to a Repeater using the new ASP.NET 4.5 strongly typed data binding.
Then I would have to put down KeyValuePair<...
11
votes
2
answers
1k
views
Difference between <%: %> and <%#: %> in Asp.Net
I know that we can <%: %> syntax for html encoding that is introduced in .Net 4. But I was reading new features of Asp.Net 4.5, and I got that we have another type i-e <%#: %> that is used ...
10
votes
1
answer
46k
views
How to pass/receive multiple args to a RESTful Web API GET method?
The usual examples of GET RESTful methods that take a parameter (returning a scalar value rather than a dataset) are shown like so:
public string Get(int id)
{
//get and return the value
}
......
10
votes
2
answers
3k
views
Using the same template for edit and insert in a list view
I am using WebForms .NET 4.5 and a asp:ListView and model binding. Within that I am using the:
<EditItemTemplate>
<InsertItemTemplate>
to define the appearance of the control. However 99%...
10
votes
3
answers
3k
views
How to add reference in VS 2015/.NET 4.6?
Has VS 2015 changed drastically on how references are added?
I am doing a MVC web project. I wanted to use System.Configuration.ConfigurationManager in my .NET 4.6 application. I went to the the ...
9
votes
5
answers
13k
views
ASP.Net MVC 4 I need to Delay execution
I have an ASP.Net MVC 4 application that periodically calls an external API for information (resource). This resource has a rate limiter for the account (meaning other apps use the same pool and may ...
9
votes
4
answers
10k
views
Object of type 'System.Int32' cannot be converted to type 'System.Web.Security.Cryptography.Purpose'
I am getting this error now whenever I try to build. I just installed Visual Studio 2012 and .Net 4.5, but this project is still on 2010.
Here is the line of code I am having issues with:
private ...
9
votes
2
answers
5k
views
ManagedPipelineHandler for an AJAX POST crashes if an IE9 user navigates away from a page while that call was in progress
Scenario:
User is using IE9 (IE8/10 not affected).
User has an active session.
Page starts an AJAX POST (GET not affected) request to a controller with the SessionState(SessionStateBehavior.Required) ...
9
votes
5
answers
5k
views
Using the new Model Binding in asp.net 4.5 to format date fields
In the olden days before asp.net 4.5 we could easily bind a date to a Gridview, Formview or other databound control and make it look presentable with a simple format string.
<asp:...
9
votes
0
answers
4k
views
httpCompression override in web.config ASP.NET IIS7.5
I have this code in my web.config for an ASP.NET 4.5 website running in IIS 7.5
<system.webServer>
<urlCompression doStaticCompression="true" doDynamicCompression="true"
...
8
votes
3
answers
13k
views
AjaxControlToolkit 7.0123 breaks VS2012 Web Application Project
I have an existing VS2012 web application that has been running fine until I added in the latest AjaxControlToolkit (7.0123). Initially, I found that the installation broke the behaviour of the ...