Menu
  • HOME
  • TAGS

ASP.NET 5 (vNext) - Getting a Configuration Setting

c#,asp.net,asp.net-5

I highly recommend using the OptionsModel instead of reading the configuration directly. It allows strong typed model binding to configuration. Here is an example: https://github.com/aspnet/Options/blob/dev/test/Microsoft.Framework.OptionsModel.Test/OptionsTest.cs#L80 For your particular case create a model: class AppSettings { public string SomeSetting {get;set;} } and then bind it to your configuration: var config =...

'Console' does not contain a definition for 'ReadKey' in asp.net 5 console App

c#,asp.net-5,vs-2015-preview

Basically, Console.ReadKey is available in the full framework, but isn't available in .NET Core. That's why it's saying it's "Available" for ASP.NET 5.0 (building against the full framework) but "Not available" for ASP.NET Core 5.0 (building against CoreCLR). Either stop using it, or only build against the full framework -...

Unable to use Serilog in Controller in asp.net 5

asp.net-5,serilog

Try some other level than Debug, I've got Serilog working except for the Debug level, not sure if its a bug or a config issue.

Convert regular class library to ASP.NET 5 (vnext)

c#,asp.net-5

There's 2 solutions: Use Shared code You can create an ASP.Net class library and ask it to compile .cs from your other class library. To do that add in your project.json add the compile option: { ... "compile": [ "**\\*.cs", "..\\Shared\\*.cs" ], ... } In this sample the code in...

How to configure email settings in ASP.NET 5?

asp.net-5,asp.net-mvc-6

Try this as a way to keep your secrets secret. First, install the SecretManager and configure it with your secrets. When you're on your local machine, you'll want to use values from the SecretManager. With your hosting (e.g. in Azure) you'll use environmental variables. Local: Install and Configure the SecretManager...

Can I use roslyn and the new .net project format to create classes on build?

c#,.net,asp.net-5,roslyn,.net-core

You can add a precompilation step, similar to what Razor does to precompile views: https://github.com/aspnet/Mvc/blob/64e726d2b26422c5452475627e4afaba307edec3/src/Microsoft.AspNet.Mvc/RazorPreCompileModule.cs Here's another example: https://github.com/aspnet/dnx/blob/e937e25ab3453ea86bda13c1297c41011dfda9de/ext/compiler/preprocess/Internalization.cs And this is how you hook it up https://github.com/aspnet/dnx/blob/3d20719b0a985b6960a3f87d9f5f9b6c3f71b7bc/src/Microsoft.Framework.Runtime/project.json#L16-L18...

Accessing dependency injected services in MVC 6

configuration,asp.net-5,asp.net-mvc-6

In general where ever you have access to HttpContext, you can use the property called RequestServices to get access to the services in DI. For example, to get access to the ILogger service from within ObjectResult. public override async Task ExecuteResultAsync(ActionContext context) { var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<ObjectResult>>(); The above usage...

MVC 6 OpenIdConnect

asp.net-5,asp.net-mvc-6,openid-connect

The problem you are having is related to the Cookie header and it's beyond the limit of HTTP.sys if the 400 error you are getting is "HTTP Error 400. The size of the request headers is too long.". The Azure AD cookie header probably exceeds the limit for a single...

IApplicationBuilder exists in both Microsoft.AspNet.Http.Abstractions and Microsoft.AspNet.Http

asp.net,asp.net-5,roslyn

You've probably "crossed the streams", as is being said by the ASP.NET teams. Make sure you're following the breaking changes and aren't including packages from multiple beta versions (make sure you don't have both beta4 and beta5 referenced, for example - easiest way to check is search your project.lock.json for...

Can the project.json file in an asp.net 5 (dnx) project be moved?

asp.net-5,visual-studio-2015,dnx,.net-5.0

Short answer is "no". The new project system assumes two things: (1) folder name = project name and (2) project.json is in that folder. project.json is not a configuration file. It is the project metadata just like csproj is for C# projects While you still need to have a folder...

Correct way to get instance of IHostingServices

c#,asp.net,asp.net-5

After doing extensive research, I've came up with the following conclusion: There are two main ways in which you may need to resovle dependencies: When creating an instance of a class using a constructor When invoking a method 1. When creating an instance of a class Using an attribute... [FromServices]...

What is the difference between 'dependencies' and 'frameworkAssemblies' in project.json?

asp.net,asp.net-5

frameworkAssemblies refers to assemblies present in GAC (global assembly cache). Consider the following example: I want to use ADO.NET apis(SqlConnection, SqlCommand) to work with a SQL Server database. I know that these apis are part of System.Data.dll and so want to reference it. Now when the full version of .NET...

Where to find 'dnu' command in Windows

asp.net-5,dnx

It should be in %userprofile%\.dnx\runtimes\<runtime name>\bin. If it is not on the path, run dnvm upgrade. If dnvm is not recognized, install it by following the instruction on the Home repo...

K ef command gives “k : System.Exception: Unable to locate project.json ”

asp.net-mvc,asp.net-5

Correct command to use is : dnx . ef migration add initial //NEW & working through cmd.exe in the projects directory k ef migration add //OLD -- DO NOT USE -- Doesn't work anymore ...

ASP.NET vnext overriding status code set in controller. Is this a bug?

osx,asp.net-5,kestrel

The behavior of void returning action was recently changed to not convert to 204 status code. However, for you scenario you could use the CreatedAtRoute helper method(this actually creates a CreatedAtRouteResult) which sets the Location header. [HttpPost] public void Post([FromBody]CrudObject crudObject) { return CreatedAtRoute(routeName: "GetByIdRoute", routeValues: new { id =...

MVC 6 install as a windows service

asp.net-5,asp.net-mvc-6,dnx

I am afraid the answer is no for this. I have been looking into this as well and the best way to do this is to deploy your project into a known location on disk and have a Windows Service to spin up the process which calls the cmd file....

EF7 Beta 4 : AddEntityFramework dont accept argument (Configuration)

asp.net-5,entity-framework-7

It looks like the tutorial you're following is using an older version of the EF7 framework. EntityFramework 7 beta 4 no longer accepts any parameters to AddEntityFramework. It looks like beta 5 is still on this same track, too. I believe what you're looking for is this: // Register Entity...

Run ASP.NET5 web application with Kestrel server on Windows

asp.net-5

The error would seem to indicate a mismatch between the runtime being used, the runtime expected by the application, and possibly the dependencies available for the specific runtime. First use dnvm list and verify which runtime is being used (active). Please post that in an update. If the wrong runtime...

How do you make an ASP.Net 5 Application be able to consume class libraries?

asp.net-5,visual-studio-2015

When downloading your project and building, I got the following error in the output: C:\REDACTED\AspNet5Test\src\AspNet5Test\Startup.cs(26,25,26,38): DNX Core 5.0 error CS0246: The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?) Note, especially the DNX Core 5.0 portion - .Net 4.5...

Deploy MVC 6 app in IIS

asp.net-5,visual-studio-2015,asp.net-mvc-6

File System publish is actually exactly what you want; All DNX applications are stand-alone, whether for ASP.NET 5 or a console app. When you publish to the File System, you get a few folders; the wwwroot (assuming you kept the default in your project.json) folder is where IIS should point....

Package Manager in VS2015 RC fails on installing/restoring some packages

nuget,asp.net-5,visual-studio-2015,dnx

Finally I found out what was wrong. I had ".nuget\NuGet.config" file somewhere above of my solution in folder structure. That NuGet.config contained a package source with relative file path: <configuration> <packageSources> <add key="local" value="..\..\..\Release"/> </packageSources> </configuration> As I removed that packageSource Package Manager in VS started working. It's kinda ridiculous....

Couldn't determine an appropriate version of runtime to run

iis-express,asp.net-5,visual-studio-2015,dnvm

It turns out that it was a simple problem. After reading https://github.com/aspnet/Announcements/issues/3, I realized that I had changed aspnet50 to dnx46 whereas it should have been dnx451. After making that change in all of my project.json files, my issue was resolved. Snippet: "frameworks": { "dnx451": {} },...

CORS for static HTML in vNext

cors,asp.net-5,asp.net-mvc-6

In Startup.cs Configure the policy in ConfigureServices ... public void ConfigureServices(IServiceCollection services) { options.AddPolicy("AllowEverything", builder => { builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().AllowCredentials(); }); } Then in Configure set the app to use the policy, then set UseStaticFiles ... Ensure that UseStaticFiles() comes after UseCors - at least in the version I'm using (installed with...

Dependency Injection asp.net 5 custom classes, what is correct way?

c#,asp.net,model-view-controller,asp.net-5

[FromServices] is just an MVC concept. It is not available to other parts of the ASP.NET 5 stack. If you want to pass dependencies down the chain you have a few options: Pass the service provider. This is quite an anti-pattern because your objects need to depend on the DI...

Public Files in ASP.NET 5

asp.net,asp.net-5

During development and production, you need to put stuff under the webroot if you have it defined. You can do this by gulp or grunt task. See here for an example. Assuming you have the following structure: └───wwwroot ├───js │ └───foo.js │ └───bar.js You will be able to reach out...

Project updated from beta-3 isn't producing outputs on build

asp.net-5,visual-studio-2015

As it turns out, when upgrading projects, some of the imports tend to get placed in the wrong order. In my upgraded .xproj, at the bottom, I found these lines: <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" /> <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" /> When I compared this with a fresh .xproj file, they were as follows: <!--...

How to register custom UserStore & UserManager in DI

asp.net-5,asp.net-mvc-6,asp.net-identity-3

DI in general is intended for interface-driven development; .AddUserManager<ApplicationUserManager>() specifies an implementation UserManager<>, not the service interface. That means that it's still expecting you to get UserManager<ApplicationUser> and only use it that way; it'll give you an ApplicationUserManager. I'm assuming that you have additional methods you want to use on...

Observer for fire&forget Task

asp.net-5

The bottom line is that ASP.NET was not designed for doing work that is not an HTTP request. There's a few different ways to try to hack together a fire-and-forget situation (as I describe on my blog), but none of them are foolproof. WebJobs, on the other hand, are designed...

Why do I have to call app.UseErrorHandler before app.UseMvc in ASP 5 for it to work?

c#,asp.net,asp.net-web-api,error-handling,asp.net-5

Because route order in ASP.NET is important. Configuring big things first and details later is not what the system is expecting. ASP.NET checks the first route. If it matches, then it doesn't check the rest of the routes. For further details, see this blog post I found. It's for an...

.vs\config\applicationhost.config in source control

iis-express,asp.net-5,visual-studio-2015

You should ignore .vs folder all together. However, there are cases where you want to persist some config on your applicationhost.config file such as registering FQDN as explained here. For this type of config, you want to use the global application host file where you can persist your changes. In...

db.database.ExecuteSQLCommand equivalent in EF 7

entity-framework,asp.net-5,asp.net-mvc-6,entity-framework-7

The feature isn't implemented yet. Track its progress using issue #624. Here is a crude extension method you can use for now. public static int ExecuteSqlCommand(this RelationalDatabase database, string sql) { var connection = database.Connection; var command = connection .DbConnection.CreateCommand(); command.CommandText = sql; try { connection.Open(); return command.ExecuteNonQuery(); } finally...

Getting a scoped component from a IDocumentStoreListener

dependency-injection,ravendb,asp.net-5

You can actually access RequestServices off of the HttpContext to get scoped instances. It's kind of backwards, and really will depend on Microsoft.AspNet to do it, but it will work for your situation; interestingly, IHttpContextAccessor is a singleton, too, though it gives you a scoped value. // injected: IHttpContextAccessor httpContextAccessor;...

How do I access the IApplicationEnvironment from a unit test?

asp.net-5,xunit,xunit2

Well, it's not ideal but you can use the static service locator to get to it: var appEnv = CallContextServiceLocator.Locator.ServiceProvider .GetService(typeof(IApplicationEnvironment)) as IApplicationEnvironment; I am not sure if xUnit injects framework dependencies in through the constructor and I bet it doesn't. If it does though (which would be perfect), you...

How to account for Properties.Settings.Default in ASP.NET 5

asp.net,asp.net-5,asp.net-mvc-6

There is no known way to make this work. See https://github.com/aspnet/Home/issues/591...

Kestrel on AspNet vNext doesnt serve index page under /

asp.net-mvc,osx,asp.net-5,asp.net-mvc-6,kestrel

You need to enable the DefaultFilesMiddleware using UseDefaultFiles() and place it before the call to UseStaticFiles(): app.UseDefaultFiles(); app.UseStaticFiles(); If you don't specify otherwise, the middleware uses the DefaultFilesOptions by default, which means this list of default file names will be used: default.htm default.html index.htm index.html See MSDN...

OSX Error dnvm: command not found

asp.net-5,dnvm

run source dnvm.sh after brew install dnvm and try to run dnvm then. Preferably, put this on your shell profile (e.g. inside .profile file) so that it will persist.

Request.IsAuthenticated function in Asp.Net 5

asp.net-5

If you just need to know if the User object is authenticated, this property should do the trick: User.Identity.IsAuthenticated If you need to prevent an action from being called by an unauthenticated user, the following attribute class works great. public class BasicAuthAttribute : ActionFilterAttribute, IAuthenticationFilter { public void OnAuthentication(AuthenticationContext filterContext)...

Output caching of API controllers in ASP.NET 5

.net,asp.net-web-api,asp.net-5,http-caching

Yes, you will be able to use the ResponseCacheAttribute. Because there is no difference between a Web Api Controller and an MVC Controller, you will be able to use the same attributes for both. This will apply whether it is the ResponseCacheAttribute, AuthorizeAttribute, RouteAttribute, or any others....

How to setup a TeamCity build for a ASP.NET 5 project

msbuild,teamcity,asp.net-5,dnx

We (the ASP.NET team) use TeamCity as the build server. Each repo has a build.cmd file, similar to this one. TeamCity simply invokes that file. For Mac/Linux builds, there is a build.sh file....

Get injected IOptions

asp.net-5

In your ConfigureServices method, try adding the following: services.AddOptions() This registers OptionsManager<> which is used to resolve the services of type IOptions<>....

How to install DNX Secret Manager in Mac OSX

osx,asp.net-5,dnx

Sorry, that is a known issue and we've fixed in beta5. You have two options: Pass the fallback source: dnu commands install secretmanager 1.0.0-beta4 -f https://www.myget.org/F/aspnetrelease/api/v2 Update to the latest beta5 bits ...

VS2015 using the Nightlies

asp.net,asp.net-5,visual-studio-2015

The feed link you are setting is incorrect. The correct one is: https://www.myget.org/F/aspnetvnext/api/v2

Aurelia project setup and folder structure in Visual Sudio 2015: what goes in wwwroot?

asp.net-5,visual-studio-2015,aurelia

I spent quite some time on this and finally settled on: ApplicationName src Api In here I have an ASP.NET 5 project that provides the api to be consumed by the Aurelia app. You will likely need to turn on CORS to avoid errors. Client.Web In here I started with...

Resolve dependencies when calling constructor using DI with ASP.NET 5

c#,asp.net,asp.net-5

First, you'll want to make sure the class you want to construct is registered with the DI container. (Given your example of a controller, it probably already is thanks to the MVC framework.) There's several ways to do this, the most basic of which is registering a Transient. Note this...

View code changes without restarting the server

c#,asp.net,asp.net-5,vscode,dnx

This is the expected behavior. You can use something like gulp-aspnet-k to automate this process. More detailed info available here: Building and Running Your ASP.NET vNext Application with Gulp. Note that this gulp integration unfortunately only works on Windows now but all it does is to watch the dnx process...

WS-Federation sign-in Asp.NET 5 MVC 6 ADFS

asp.net,asp.net-5,adfs,asp.net-mvc-6,ws-federation

As you already figured out, the WS-Federation middleware has not been ported to ASP.NET 5 yet, but don't panic, it will definitely be: https://twitter.com/blowdart/status/610526268908535808 In the meantime, you can use the OWIN/Katana 3 WS-Federation middleware in an ASP.NET 5 application with a tiny IAppBuilder/IApplicationBuilder adapter (like this one: https://github.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Server/blob/vNext/samples/Mvc/Mvc.Server/Extensions/AppBuilderExtensions.cs#L50), but...

Equivalent of RouteData.GetRequiredString in ASP.NET 5

asp.net,asp.net-mvc-routing,asp.net-5

You could create an extension yourself. namespace Microsoft.AspNet.Mvc { public static class HelperExtensions { public static string GetRequiredString(this RouteData routeData, string keyName) { object value; if(!routeData.Values.TryGetValue(keyName, out value)) { throw new InvalidOperationException($"Could not find key with name '{keyName}'"); } return value?.ToString(); } } } ...

How should I reference HttpClient for dnx451 and dnxcore50?

c#,.net,asp.net-5,dotnet-httpclient,.net-core

As of the time of posting (June 11, 2015) this is the combination that worked for me for both dnx451 and dnxcore50. { "dependencies": { "Microsoft.AspNet.WebApi.Client": "5.2.3" }, "frameworks": { "dnx451": { "frameworkAssemblies": { "System.Net.Http": "4.0.0.0" } }, "dnxcore50": { "dependencies": { "System.Net.Http": "4.0.0-beta-22816" } } } } ...

How is execution passed from the clr to Startup class (startup.cs)?

asp.net-5,dnx

DNX knows how to load and execute assemblies that have class named Program which has a method named Main. You are passing Microsoft.AspNet.Hosting as the startup assembly to DNX when you run the web command. Hosting has a Main method. This code that eventually gets called from the Main method...

Using Routing to return a WebForms page

c#,webforms,asp.net-5,asp.net-routing,asp.net-mvc-6

There is no support in ASP.NET 5 for Web Forms or the ASPX view engine. What you can do is redirect to a WebForm application on .NET 4.5/4.6, or better yet port your default.aspx to razor. As for the answer above - ASP.NET 5 does not yet support Web Pages....

Using Startup class in ASP.NET5 Console Application

c#,asp.net-5,asp.net-mvc-6

What you're looking for is the right idea, but I think you'll need to back up a moment. Firstly, you may have noticed that your default Program class isn't using static methods anymore; this is because the constructor actually gets some dependency injection love all on its own! public class...

ASP.NET 5 Custom roles for Windows Authentication

asp.net,asp.net-mvc,authentication,windows-authentication,asp.net-5

You don't set up custom roles. You need to create a custom authorization attribute, as described here. UPDATE: Yes, you can use your custom authorize attribute globally. Let's say here's your custom authorize attribute: public class MyAuthorizeAttribute : AuthorizeAttribute { protected override bool AuthorizeCore(HttpContextBase httpContext) { var username = httpContext.User.Identity.Name;...

SignalR, ASP.NET 5 and CORS

signalr,cors,asp.net-5

Seen with SignalR team, this is working on http://localhost:port but not on file:///C:/Users/me/Documents/index.html and this is normal.

Unable to add any nuget dependency with ASP.NET 5

nuget,asp.net-5,visual-studio-2015

Here's the problem: <disabledPackageSources> <add key="nuget.org" value="true" /> </disabledPackageSources> The nuget.org source is disabled...

Create a method/function to use within a view

asp.net-5,asp.net-mvc-6

Referring to a few design discussions that we only have glimpses of online, @helper was removed for design reasons; the replacement is View Components. I'd recommend a View Component that looked like the following: public class ConfigurationKeysViewComponent : ViewComponent { private readonly IConfiguration config; public ConfigurationKeysViewComponent(IConfiguration config) { this.config =...

How to publish a Asp.net 5 MVC6 website on IIS containing two web apps

asp.net-5,visual-studio-2015,asp.net-mvc-6

How did you deploy? Here are the steps that you can follow to get that running: Make sure that you the app pool is a .NET 4 app pool Run, in your web app's project folder dnu publish --runtime <name of runtime> (the name is the name of the runtime...

How do you configure SQL Session State in ASP.NET 5.0 (vNext) MVC 6? [closed]

sql-server,configuration,session-state,asp.net-5,asp.net-mvc-6

Support for SQL Server Session State is currently in development. So your best options for now are using In-Memory session(which has the issue which you mentioned about state not persisted for multiple servers behind load balancer kind of scenarios). However you could try using Redis cache(ASP.NET 5 Session implementation is...

NotNull attribute

c#,asp.net-5

The attribute will be replaced through a precompilation step, using Roslyn, by code that does the actual check. However, the feature is not yet ready. It will come in a later version....

Can an ASP.NET 5 application be published such that the target machine doesn't need DNX installed?

c#,asp.net,.net,asp.net-5

In theory, you should be able to deploy your application into a machine where even .NET Framework is not installed but I remember hearing that even the dnxcore has some .NET Framework dependencies today and will be gone later (I could be mistaken, it's worth trying this out). Assuming this...

Web API Authentication in ASP.NET 5

c#,asp.net,authentication,web-api,asp.net-5

Indeed, there'll be no OAuthAuthorizationServerMiddleware in ASP.NET 5. If you're looking for the same low-level approach, you should take a look at AspNet.Security.OpenIdConnect.Server: it's an experimental fork of the OAuth2 authorization server middleware that comes with Katana 3 but that targets OpenID Connect, as you already figured out ( OAuth...

How to get Microsoft.AspNet.Http.HttpContext instance in Class Constructor using DI

c#,asp.net-mvc,dependency-injection,asp.net-5,asp.net-mvc-6

Inject IHttpContextAccessor in the constructor

How to Force Visual Studio to Use a Specific Version of DNX

c#,asp.net,asp.net-5,dnx,dnvm

Put the DNX version inside the global.json file which lives on the root directory of your solution (like here). { "sdk": { "version": "1.0.0-beta4" } } You may need to restart the Visual Studio. The other way is to configure this through project properties dialog inside Visual Studio: ...

HandleUnknownAction in ASP.NET 5

asp.net-5,asp.net-mvc-6

There's no real equivalent. Action Selection in MVC5/WebAPI2 was a three stage process: 1. Run the routes 2. Select a controller 3. Select an action In MVC6, step 2 is gone. Actions are selected directly using route values - you'll notice that Controller.BeginExecute is gone as well. Controllers are 'thin'...

How to change PasswordValidator in MVC6

asp.net-mvc,asp.net-identity,asp.net-5,asp.net-mvc-6

The Solution In the Startup.cs write the code: services.ConfigureIdentity(options => { options.Password.RequireDigit = false; options.Password.RequiredLength = 6; options.Password.RequireLowercase = false; options.Password.RequireNonLetterOrDigit = false; options.Password.RequireUppercase = false; }); ...

Access connection strings

azure-web-sites,asp.net-5

The connection strings are set as environment variables. Therefore, first you have to add the environment variable configuration source and then the connection strings will be named Data:NAME:ConnectionString where NAME is the name of the connection string in the portal. For example, if your connection string is "ServerConnection" then you...

How to Make ASP.Net 5 Reference Normal .Net Class Library that is not in your solution

asp.net-5,visual-studio-2015,dnx

To reference a DLL on your machine but not in your Solution, you'll need to update the project.json as follows: { "frameworks" : { "dnx451" : { "bin" : { "assembly": "<path to dll>", "pdb": "<path to pdb if needed>" } } } } Unfortunately, much of the dnx tooling...

Multiple Posted Types asp.net 5 MVC 6 API

c#,asp.net,asp.net-mvc,asp.net-5,asp.net-mvc-6

The best way is to create a composite wrapper: public class Wrapper { public ModelA A { get; set; } public ModelB B { get; set; } } Put Wrapper in the parameter list and mark that [FromBody]. You can't use that attribute more than once because all of the...

Getting a Configuration Value in ASP.NET 5 (vNext)

c#,asp.net,asp.net-mvc,asp.net-5,asp.net-mvc-6

You are entangling 2 different run time resource provider, AppSettings and Dependency Injection. AppSettings, provides run-time access to Application specific values like UICulture strings, Contact Email, etc. DI Containers are factories that Manage access to Services and their lifetime scopes. For example, If a MVC Controller needed access to your...

ASP.NET 5 Web API doesn't return XML

xml,asp.net-web-api,content-type,asp.net-5

By default Xml formatters are not included as part of the Microsoft.AspNet.Mvc package. You need to reference another package called Microsoft.AspNet.Mvc.Xml for this. Example on how you can add the formatters: public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMvc(); services.ConfigureMvc(options => { // This adds both Input and Output formatters based on...

How to specify constructor when registrating class in asp.net 5 with default Dependecy Injection

dependency-injection,asp.net-5

Unfortunately, the out of the box DI container does not support parameter constraints. It is all or nothing. If you want advanced features, you can switch to another DI container, like Autofac, that you already mentioned and that is supported in ASP.NET 5....

Entity Framework 7 group by

asp.net-5,asp.net-mvc-6,entity-framework-7

It doesn't look like this is currently supported, but it looks like someone saw this post and created the linked issue. The concept is a fairly complex bit of logic, and EF7 is very much in an early phase. .Net's GroupBy doesn't translate directly to SQL's GROUP BY until you...

aspnet vNext ActionFilter and TempData

c#,asp.net-mvc,asp.net-5

To access TempData from within an action filter, you can get the service called ITempDataDictionary from DI. To get this service from DI, you could either do something like actionContext.HttpContext.RequestServices.GetRequiredService<ITempDataDictionary>() from within your OnActionExecuting method. You could also use construction inject if you like by using ServiceFilterAttribute. NOTE: TempData by...

Why is the EmbeddedFileProvider not hierarchical?

asp.net-5

In the latest version of DNX we made a change so that embedded files and resources do not retain their path: / gets replaced by .. The hierarchy is flattened to names that are valid C# full type names. It is the same thing that MSBuild did before. Since ....

What are my options for sharing code between DNX / ASP.NET 5 projects (project.json / xproj) and other C# projects (csproj) within a single solution?

.net,asp.net-5,dnx,.net-core

Take a look at what EntityFramework does. They target 3 TFMs: net45, .NETPortable,Version=v4.5,Profile=Profile7, frameworkAssemblies and they have both csproj and xproj in the same folder. Basically, for each project you have two project files. However I cannot find a way to reference ClassLibrary-dnx from WindowsService.csproj. Unfortunately, that's not possible, yet....

How to pass a URL as a query string parameter in MVC

c#,asp.net-5,asp.net-mvc-6

Thanks so much for all the answers. Finally I got it sorted. Please refer to my fix below: [Route("api/[controller]")] public class UrlController : Controller { [HttpGet("{*longUrl}")] public string ShortUrl(string longUrl) { var test = longUrl + Request.QueryString; return JsonConvert.SerializeObject(GetUrlToken(test)); } ...

EntityFramework 7 database already exists error on migrations

asp.net-5,entity-framework-7

Connect to (localdb)\mssqllocaldb in SQL Server Management Studio, delete the database there. I'm not sure why this step is required or why the migrations fails, however.

visual studio 2015 doesn't see my xunit tests

asp.net-5,visual-studio-2015,xunit.net

On another computer, this is working http://xunit.github.io/docs/getting-started-dnx.html Maybe installation problem... Thanks to agua from mars anyway...

Token Based Authentication in ASP.NET 5 (vNext) (refreshed)

c#,authentication,authorization,web-api,asp.net-5

Generate an RSA key just for your application. A very basic example is below, but there's lots of information about how security keys are handled in the .Net Framework; I highly recommend that you go read some of it, at least. private static string GenerateRsaKeys() { RSACryptoServiceProvider myRSA =...

Microsoft azure redis cache with DNX core 5

asp.net-5,stackexchange.redis,dnx

Unfortunately, StackExchange.Redis hasn't been updated for DNX Core. Even Microsoft references it in Microsoft.Framework.Caching.Redis. As another note, unless you're doing something specific with Redis, I suggest you look at the Caching framework interfaces; this will let you vary to other technologies for your caching solution, and won't require you to...

Kestrel Running which framework?

azure,asp.net-5,dnx,dnvm,.net-5.0

In Visual Studio 2015, the framework used is determined in this order: The project properties. Right-Click the .xproj in your Solution Explorer and select Properties. Head to the "Application" section (the default), and you can "Use Specific DNX version", including version, platform, and architecture. The global.json. I don't know if...

Asp.net 5 Web template missing Bower files

gulp,asp.net-5

Go to the Task Runner Explorer in Visual Studio, right click on the copy task, and click run. I'm not sure how the files got removed or why this was necessary, but it does fix the problem. ...

How to run nunit tests with asp.net 5 projects, espically with ReSharper?

nunit,resharper,asp.net-5

DNX tests aren't currently supported by ReSharper. It's a whole new execution model, and hasn't yet been implemented for ReSharper. I'd expect to see support as DNX and asp.net stabilise and near release. Also, I don't believe nunit itself supports running as a DNX test runner - the xunit team...

Using HttpClient in ASP.NET 5 app

asp.net,httpclient,asp.net-5

Did you try Microsoft ASP.NET Web API 2.2 Client Library Just add reference to your project.json file as below: "dependencies": { "Microsoft.AspNet.WebApi.Client": "5.2.3" } And after package restore, you can call your Web Api like below: using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://yourapidomain.com/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));...

What is the ASP.NET 5 equivalent of HostingEnvironment.VirtualPathProvider

asp.net,asp.net-mvc,asp.net-5

You need to trim the leading ~. MVC does this when it calls into the hosting environment, so coding with MVC apis makes it feel like ~/ is still supported to keep back compat working. The core API though has no notion of ~/ See https://github.com/aspnet/Mvc/blob/bd03142daba3854ac976906588bcaa1dc98accd0/src/Microsoft.AspNet.Mvc.Core/ActionResults/FilePathResult.cs#L151...

How to suppress warnings when building an ASP.NET 5 project?

asp.net-5

This is not yet supported, the DNX team will try to add it in beta 6: https://github.com/aspnet/dnx/issues/2042.

How to Edit and Continue in ASP.Net MVC 6

c#,asp.net-5,visual-studio-2015,asp.net-mvc-6

Edit and Continue does not work for ASP.NET 5 applications at this point in Visual Studio 2015, but it is planned to support it in the final 2015 release. For more information about VS2015 ENC changes, have a look at this blog entry: http://blogs.msdn.com/b/visualstudioalm/archive/2015/04/29/net-enc-support-for-lambdas-and-other-improvements-in-visual-studio-2015.aspx...

dnx451 actually means .net 4.5

asp.net-5

This warning doesn't seem to mean much. It it still visible even if .net version of web project is set to be greater than library's e.g. "net46": { "dependencies": { "Lib01": "1.0.0-*" } } Another interesting thing that it's possible to have library build against .NET Framework 4.6 (latest) and...

Deploying a Standard vNext WebApplication VS Next 2015 RC to Bluemix fails

cloudfoundry,asp.net-5,bluemix

The ASP.NET 5 buildpack in Bluemix only supports Beta3 right now. It will support Beta 4 in the near future. Please keep an eye on https://github.com/cloudfoundry-community/asp.net5-buildpack.

Application_Start equivalent in ASP.NET 5

asp.net-5

As Simple Man said, there is no direct equivalent method in ASP.NET 5; similar functionality should be started by your services when appropriate in keeping with the Single Responsibility Principle. (The closest is the Configure method, which is where you should probably "start" any services that need to be "started".)...

How do I set the TypeScript compiler version for an ASP.NET 5 MVC 6 project in Visual Studio 2015 RC?

asp.net-5,visual-studio-2015,asp.net-mvc-6,typescript1.5

There is no way to do this in ASP.NET 5 natively. This is something you should handle inside gulp or grunt tasks. See this sample grunt task for typescript. It is based on the dependency you have for grunt typescript plugin.

Access ASP.NET 5 View Component via URL

asp.net-5,asp.net-mvc-6

You cannot access a view component from a URL directly. A view component is just a component of a view and that view could be a regular or partial view. Based on your question, I believe you are trying to show the first page by default when the view (having...

Web api with mvc 6 get element based on string

c#,asp.net-mvc,asp.net-web-api,asp.net-5,asp.net-mvc-6

Just remove :string. You're not really constraining the value of the id anyway - it's already a string in the URL. This fairly old blog post lists the available constraints - and you can see there's no :string constraint, because you don't need there to be. The constraints are used...