FAQ Database Discussion Community


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

asp.net-5,visual-studio-2015
Step 1: Open VS 2015 RC and create a new "ASP.Net Web Application" Step 2: Right-click the solution, add a new windows "Class Library" (a normal one, not the "Class Library (Package)" Step 3: Put a method in Class1.cs in the class library. Doesn't matter what. Step 4: Right-click "References"...

ASP.NET 5 Custom roles for Windows Authentication

asp.net,asp.net-mvc,authentication,windows-authentication,asp.net-5
I'm building an intranet type site with ASP.NET 5 that uses Windows Authentication. I have the authentication working, but I don't want everyone on the domain to have access to the intranet site. I can't use domain roles so I've set up my own custom roles in my SQL Server....

Entity Framework 7 Migration Scaffolding in Class Library with Configuration

code-first-migrations,asp.net-5,visual-studio-2015,entity-framework-7,dnx
Trying to add migrations to an EF7 Model that lives in an ASP.NET 5 class library. When running dnx . ef migration add mymigration fails with different results depending on which project I run it on. If I run it in the folder of the main project, it cannot locate...

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

asp.net,asp.net-5,adfs,asp.net-mvc-6,ws-federation
Hello so I've been trying to achieve WS-Fed SSO on my MVC6 web application, I've read a bit on authentification and all to identify my requirements. I have to use WsFederationAuth so no oauth nor saml protocol would work for me. Edit : After @Pinpoint suggestion I tried to use...

How to configure email settings in ASP.NET 5?

asp.net-5,asp.net-mvc-6
How to configure mail settings <system.net><mailSettings> that used to be in web.config in asp.net 4? I guess I need to call services.Configure<>() but I have no idea what options I should pass. Any ideas? Thanks, f0rt...

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
I created an ASP.NET 5 application for Web API and installed Asp.Net.Diagnostics from NuGet so I could add my own error handling. What works: (From Configuration function in Startup.cs) app.UseErrorHandler("/Home/Error"); app.UseMvc(routes => { routes.MapRoute("Default", "{controller=Home}/{action=Index}/{id?}"); }); What doesn't work: (app uses normal error handler instead of the custom one) app.UseMvc(/*..configure...

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

c#,authentication,authorization,web-api,asp.net-5
I'm working with ASP.NET 5 (vNext) application. I'm trying to implement Token Based Authentication but can not figure out how to use new Security System. My scenario: A client requests a token. My server should authorize the user and return access_token which will be used by the client in following...

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

c#,asp.net,asp.net-5
I'm writing a basic app to learn ASP.NET 5. One area I find very confusing is configuration. Prior to ASP.NET 5, I could do the following: var settingValue = ConfigurationManager.AppSettings["SomeKey"]; I would have lines of code like that sprinkled throughout my code. Now, in the vNext world, I have a...

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

asp.net-5,visual-studio-2015
After upgrading a project from the .kproj format to the .xproj format, my project is no longer producing outputs on build. When I check the project properties dialog, the checkbox for "Produce Outputs on Build" is unchecked. Checking it, saving the properties, and re-opening the project properties causes the checkbox...

How should I reference HttpClient for dnx451 and dnxcore50?

c#,.net,asp.net-5,dotnet-httpclient,.net-core
How should I reference HttpClient using a project.json file? I want both frameworks to work: dnx451 and dnxcore50. Here is my current attempt at the project.json file. (I've removed the irrelevant parts.) { "dependencies": { "Microsoft.Net.Http": "2.2.29", "Microsoft.Net.Http.Headers": "1.0.0-beta4", "System.Net.Http": "4.0.0-beta-22816" }, "frameworks": { "dnx451": { "frameworkAssemblies": { "System.Net.Http": "4.0.0.0"...

OSX Error dnvm: command not found

asp.net-5,dnvm
I am newbie to OSX. After following the step by step instructions from https://github.com/aspnet/home. brew tap aspnet/dnx brew update brew install dnvm I got the following error when I run dnvm upgrade: $ dnvm upgrade Error: -bash: dnvm: command not found I have tried locate the dnvm and looks like...

Accessing dependency injected services in MVC 6

configuration,asp.net-5,asp.net-mvc-6
I'm using mvc6 with vs2015 rc. After reading Using IConfiguration globally in mvc6, my code now looks like this: startup.cs: public void ConfigureServices(IServiceCollection services) { ... IConfiguration configuration = new Configuration().AddJsonFile("config.json"); services.Configure<Settings>(configuration); } my controller: private Settings options; public MyController(IOptions<Settings> config) { options = config.Options; } this works great for...

EntityFramework 7 database already exists error on migrations

asp.net-5,entity-framework-7
ASP.NET 5 project, Entity Framework 7. Using all the default stuff that comes with the ASP.NET 5 web template for creating the Identity Context. When I start up the app and first try to hit the context (register or log in), there is an error on Database.AsRelational().ApplyMigrations() that the database...

VS2015 using the Nightlies

asp.net,asp.net-5,visual-studio-2015
I have VS2015RC. I was looking to plug it into the nightly nuget feed. If i configure the normal way i don't get the intellisense from the nightly feed in project.json i.e Nuget Package manager Settings Also in the "Nuget Package Manager for Solution" if I change the package source...

Using Startup class in ASP.NET5 Console Application

c#,asp.net-5,asp.net-mvc-6
Is it possible for an ASP.NET 5-beta4 console application (built from the ASP.NET Console project template in VS2015) to use the Startup class to handle registering services and setting up configuration details? I've tried to create a typical Startup class, but it never seems to be called when running the...

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

asp.net-5,visual-studio-2015,dnx
Earlier I asked this question and got an answer that worked. In order to make your ASP.Net 5 application be able to reference a normal .Net class library that targets the .Net Framework 4.5, you must remove the ' "dnxcore50": { }' reference from your project.json file. Great. That worked...

Run ASP.NET5 web application with Kestrel server on Windows

asp.net-5
I have successfully run the 'HelloWeb' sample from the ASP.NET5 GitHub repo with the Kestrel server on Windows 8.1 by using: dnx . kestrel Now I want to run my own application with kestrel. I tried it from Visual Studio 2015RC and with several runtimes using dnx directly. The result...

Kestrel on AspNet vNext doesnt serve index page under /

asp.net-mvc,osx,asp.net-5,asp.net-mvc-6,kestrel
I need to be able to serve my 'index.html', under the default url /, using Kestrel web server. Right now I'm only able to access my static files with the full path i.e /index.html Again this works perfectly on VisualStudio, the context is OSX with Kestrel This is my Startup.cs...

NotNull attribute

c#,asp.net-5
I'm looking at asp.net vnext engineering guideline and have noticed that they recommend to use NotNull attribute instead of explicit checking of input argument for null and throwing ArgumentNullException. The thing that confused me is that base on this guideline it is just enough to declare this attribute and the...

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
Scenario I'm experimenting with Visual Studio 2015 RC, specifically looking at switching to the new ASP.NET 5 framework, project structure and the new DNX that runs ASP.NET 5 applications. My employer has many existing solutions targeting .NET Framework 4.5.2. In our existing Visual Studio solutions we might have the following...

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

c#,asp.net,model-view-controller,asp.net-5
Trying to understand DI. What is correct way to use services/dependency objects in custom classes? Do i need to create each class as service and add to dependency objects? Or should I be using [FromServices] (previously, [Active] before beta4 ) attribute. or is there is a service object I should...

Access ASP.NET 5 View Component via URL

asp.net-5,asp.net-mvc-6
With the replacement of partial views in ASP.NET 5 with view components, how does one access the view components via URL? I know you call them like... @Component.Invoke("SomeList", 1) ...but what if you need to have like ajax paging, where you need a callback url to request the next set...

Authentication in ASP.NET 5 (vNext)

asp.net,oauth,asp.net-5,asp.net-mvc-6
I have a traditional ASP.NET app that I want to move to ASP.NET 5 (vNext). I am doing this as a learning exercise. My current app uses Forms-based authentication. However, I would like to use OAuth. I was looking at the Security module and was curious what should be used...

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

asp.net-5
The ASP.NET 5 project has no "Suppress Warnings" option in its project property sheet. Recently I encountered a warning MSB3274 ( dnx451 actually means .net 4.5 ) and I tried to find a way to suppress this warning. I looked https://github.com/aspnet/Home/wiki/Project.json-file but found nothing related to suppress warnings....

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

asp.net-5,visual-studio-2015,aurelia
I want to start playing with Aurelia and MVC 6 Web API with Visual Studio 2015 RC, and I'm using OdeToCode's blog post as a starting point. I understand the idea behind the new wwwroot folder, but I'm basically confused as to what should or shouldn't put in there. My...

How to force all requests in ASP.NET 5 MVC project to redirect to root “/”?

asp.net-5
This post by Stephen Walther talks about redirecting all requests in an MVC project by modifying the web.config system.webServer / rewrite section. http://stephenwalther.com/archive/2015/01/16/asp-net-5-and-angularjs-part-3-adding-client-routing However, it seems wrong to have to reintroduce a web.config xml file into an ASP.NET 5 project. Is there another way to do this in ASP.NET 5?...

HandleUnknownAction in ASP.NET 5

asp.net-5,asp.net-mvc-6
What's an equivalent of ASP.NET MVC 5 Controller.HandleUnknownAction() in ASP.NET MVC 6 / ASP.NET 5?...

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

nuget,asp.net-5,visual-studio-2015,dnx
I'm trying to install a nuget package - NGenerics.1.4.1 from nuget.org (https://www.nuget.org/packages/NGenerics/) into a ASP.NET 5 project (website). Package Manager fails with UriFormatException. After that a reference is added into Reference folder in the Solution Explorer but with yellow triangle ('warning'). The error added into the Error List: "Dependency NGenerics...

visual studio 2015 doesn't see my xunit tests

asp.net-5,visual-studio-2015,xunit.net
trying to add xunit tests to my ASP.NET 5 project, i've added a class library and fill the project.json like this : { "version": "1.0.0-*", "description": "", "authors": [ "" ], "tags": [ "" ], "projectUrl": "", "licenseUrl": "", "dependencies": { "xunit": "2.1.0-beta2-build2981", "xunit.runner.visualstudio": "2.1.0-beta2-build1055" }, "commands": { "test": "xunit.runner.visualstudio"...

Asp.net 5 Web template missing Bower files

gulp,asp.net-5
ASP.NET 5 has a folder named Dependencies->Bower which the default Web template contains things like bootstrap, hammer.js, and jquery. These dependencies are copied to a lib folder according to gulpfile.js. var paths = { bower: "./bower_components/", lib: "./" + project.webroot + "/lib/" }; For some reason my site is missing...

dnx451 actually means .net 4.5

asp.net-5
I created two projects using Visual Studio 2015 RC a class library MyLib which its target framework is .NET Framework 4.5.1 an ASP.NET 5 project MyWebApp which references MyLib in project.json: "frameworks": { "dnx451": { "dependencies": { "Lib01": "1.0.0-*" } }, } When I trying to build MyWebApp, an warning...

Couldn't determine an appropriate version of runtime to run

iis-express,asp.net-5,visual-studio-2015,dnvm
I just finished upgrading to beta4. My code compiles successfully with no errors/warnings but I am unable to launch my web api hosted in IIS Express (by hitting F5). I get the following error: Couldn't determine an appropriate version of runtime to run. See http://go.microsoft.com/fwlink/?LinkId=517742 for more information. Description: An...

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

asp.net-5,dnx
The Startup class in asp.net 5 strikes me as an odd duck. It isn't class Startup : ISomething or Startup : BaseSomething where the interface or base class is part of some Microsoft.AspNet.* assembly. No Startup is just a plain class with the correct magical method signatures created by convention....

Microsoft azure redis cache with DNX core 5

asp.net-5,stackexchange.redis,dnx
Trying to use redis azure cache with an ASP.NET 5 application. In my dependencies : "dependencies": { "Microsoft.AspNet.Server.IIS": "1.0.0-beta4", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta4", "Microsoft.AspNet.Mvc": "6.0.0-beta4", "StackExchange.Redis": "1.0.450" }, "commands": { "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000" }, "frameworks": { "dnx451": { }, "dnxcore50": { } }, Code such as : private readonly...

How to change PasswordValidator in MVC6

asp.net-mvc,asp.net-identity,asp.net-5,asp.net-mvc-6
In the Asp.Net MVC 5 using Identity, was possible to do the following: manager.PasswordValidator = new PasswordValidator { RequiredLength = 6, RequireLowercase = true, RequireDigit = false, RequireUppercase = false }; How to change the same configuration in MVC 6? I see that can be in ConfigurationServices method in the...

Application_Start equivalent in ASP.NET 5

asp.net-5
I've come across two methods on the Startup class, ConfigureServices and Configure. Is there an equivalent to the Application_Start method from previous versions of asp.net for doing arbitrary work when the application is starting? Edit As a follow up, what are the possible methods that ASP.NET 5 is expecting on...

How to register custom UserStore & UserManager in DI

asp.net-5,asp.net-mvc-6,asp.net-identity-3
Here is my setup: public class ApplicationUser : IdentityUser<Guid> { } public class ApplicationRole : IdentityRole<Guid> { } public class ApplicationUserLogin : IdentityUserLogin<Guid> { } public class ApplicationUserClaim : IdentityUserClaim<Guid> { } public class ApplicationRoleClaim : IdentityRoleClaim<Guid> { } Here is the definition of my UserStore public class ApplicationUserStore :...

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
In Visual Studio 2015 RC, ASP.NET 5 vNext, i am trying to use SQL Session State in MVC 6. I'm not sure how to go about it. Can anyone show me a sample or give me some tips? I'm just trying out Azure Load Balancer. I set up a load...

Where to find 'dnu' command in Windows

asp.net-5,dnx
I have recently installed Visual Studio 2015 RC. I'm trying to figure out the new .NET Core thing... Now I want to package my application and launch it. I wanted to play with DNX Utility but can not figure out how to run it. My command prompt still insists that...

Getting a scoped component from a IDocumentStoreListener

dependency-injection,ravendb,asp.net-5
I have an ASP.NET 5 app using RavenDB, and I'm trying to create an attribute that will create a "Changeset" document with the keys of all the documents that were stored by the action. For that purpose, I created an ActionFilterAttribute instantiated via ServiceFilterAttribute, which is registered as Scoped, that...

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

c#,asp.net,asp.net-5,dnx,dnvm
I was messing around with the dnvm, and I ran dnvm upgrade, putting me into beta5. However, the project I am working on is staying in beta4 (at least for now). I have been attempting to revert and failing. I have gone as far as to delete the runtime folder....

Request.IsAuthenticated function in Asp.Net 5

asp.net-5
Is there an equivalent to Request.IsAuthenticated in Asp.Net 5 hidden somewhere or are we expected to loop through the user's identities and determine this ourselves?

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

asp.net,asp.net-5
The documentation for using project.json for ASP.NET 5 applications includes a sample project.json file (abbreviated version below). What is the difference between frameworkAssemblies and dependencies? And why does dnx451 use one and dnxcore50 use the other? { "version": "0.1-alpha-*", ... "frameworks": { "dnx451": { "frameworkAssemblies": { ... } }, "dnxcore50":...

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

asp.net,asp.net-mvc,asp.net-5
I think it is IHostingEnvironment.WebRootFileProvider but when I use its GetFileInfo(path), it doesn't find paths like ~\Images\foo.jpg. But the old API - HostingEnvironment.VirtualPathProvider.FileExists(path) - would find a path starting with ~\.

View code changes without restarting the server

c#,asp.net,asp.net-5,vscode,dnx
We're using Visual Studio Code and DNX as follows. Command Line to Start Web Server dnx . web project.json > commands "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5001" Note that we added carriage returns for readability. When we change a *.cshtml and refresh the browser, the changes show up in the...

How do you change the default environment value in ASP.NET 5 that is available via IHostingEnvironment?

asp.net-5,asp.net-mvc-6
I am accessing the environment name using IHostingEnvironment in ASP.NET 5 and it is Development by default. How do I change it to something else? I tried creating environment variable ASPNET_ENV in my Windows 7 system but that doesn't change anything. Update: The problem was resolved when I removed the...

Equivalent of RouteData.GetRequiredString in ASP.NET 5

asp.net,asp.net-mvc-routing,asp.net-5
I have several HtmlHelper extension methods that I use to create navbar buttons - one is for a context-sensitive help link. In my extension method I need to know the name of the current controller and action e.g.: var currentAction = htmlHelper.ViewContext.RouteData.GetRequiredString("action"); var currentController = htmlHelper.ViewContext.RouteData.GetRequiredString("controller"); What can I use...

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

asp.net,asp.net-5,asp.net-mvc-6
I'm referencing a third-party DLL that reads configuration from Properties.Settings.Default.DefaultHostName. How do I configure this in my ASP.NET 5 application so that their call to Properties.Settings.Default.DefaultHostName doesn't cause an exception? In previous versions of ASP.NET this would have appeared in the web.config as <applicationSettings> <DllName.Properties.Settings> <setting name="DefaultHostName" serializeAs="String"> <value>Sample</value> </setting>...

Multiple Posted Types asp.net 5 MVC 6 API

c#,asp.net,asp.net-mvc,asp.net-5,asp.net-mvc-6
I can use [FromBody] for single type , but is there any way to use multiple? From the searching and reading I've done there is not a way, but i don't know if a way has been added in MVC 6. If not, where would be best to start with...

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

c#,asp.net,asp.net-mvc,asp.net-5,asp.net-mvc-6
I am struggling with some concepts in ASP.NET 5 (vNext). One of those is the Dependency Injection approach used for configuration. It seems like I have to pass a parameter all the way through the stack. I'm probably misunderstanding something or doing it wrong. Imagine I have a config property...

aspnet vNext ActionFilter and TempData

c#,asp.net-mvc,asp.net-5
I'm trying to create an ActionFilter in aspnet vNext. Within this filter I want to access to the TempData and the ViewData (both available in Controller in previous versions).I override the method public override void OnActionExecuting(ActionExecutingContext filterContext) Into the filterContext I have the controller but is an object instead of...

Entity Framework 7 group by

asp.net-5,asp.net-mvc-6,entity-framework-7
I'm trying to run the following code but when I check the SQL profiler it looks like it runs a full select on the table and then does the grouping after it returns all results from the database. Any help is appreciated. var result = _dbContext.LogEvent.GroupBy(x => x.EventLevel) .Select(g =>...

Output caching of API controllers in ASP.NET 5

.net,asp.net-web-api,asp.net-5,http-caching
Am I correct that in ASP.NET 5 ResponseCacheAttribute has replaced OutputCacheAttribute used in previous ASP.NET MVC releases? Can it be used to cache responses of API controllers? If not, what do Microsoft offer instead? I tried two free solution for WebAPI2 but was not impressed at all.

ASP.NET 5 Web API doesn't return XML

xml,asp.net-web-api,content-type,asp.net-5
How can I have my vnext API to return XML and JSON ? I thought that using content-type with application/xml would work as it was before. Note that I tryed with Accept : application/xml too. But it seems not. EDIT : this is my project.json file : { "webroot": "wwwroot",...

EF7 Beta 4 : AddEntityFramework dont accept argument (Configuration)

asp.net-5,entity-framework-7
I am going through this example: http://stephenwalther.com/archive/2015/01/17/asp-net-5-and-angularjs-part-4-using-entity-framework-7 and i am struggling with this code part: using Microsoft.AspNet.Builder; using Microsoft.Framework.DependencyInjection; using Microsoft.Data.Entity; using creaservo.com.Models; using Microsoft.Framework.ConfigurationModel; using Microsoft.AspNet.Hosting; namespace creaservo.com { public class Startup { public Startup(IHostingEnvironment env) { // Setup configuration sources. Configuration = new...

How do I access the IApplicationEnvironment from a unit test?

asp.net-5,xunit,xunit2
How can I access the IApplicationEnvironment from an xUnit 2 unit test? There are several scenarios where I think I need this, including: Read from a non-embedded configuration file built with the unit tests Create and write files relating to the unit tests ...

Observer for fire&forget Task

asp.net-5
Disclaimer : I may have a bad idea ! I have a middleware on ASP.NET 5. This middleware process the request and start a new Task. The task is mainly for statistics purposes. The middleware do not care of the result of this task. For performances reason, I would like...

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

c#,asp.net-5
I have a problem referencing libraries in one my existing projects in my new ASP.NET 5 (vnext) project. I have found no reference on the web about converting existing libraries or changing the compile target. I've created a new ASP.NET 5 library and it has a different project structure so...

Create a method/function to use within a view

asp.net-5,asp.net-mvc-6
How can we write a function to use in a *.cshtml page. We used to be able to use @helper or @function within the view. How do we do this? For instance, I would like to write a recursive function to show all configuration values. How could I do this?...

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
So I'm now at my witts end with this one. As the question in the title asks, I'm trying to set the tsc version for a sample ASP.NET 5 MVC 6 project. I'm using Visual Studio 2015 RC and I want to compile TypeScript using version 1.5 Beta that was...

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

c#,asp.net,asp.net-5
The web seems flooded with examples on how to use DI with ASP.NET 5 but not one of the examples shows how to call a constructor and resolve dependencies. The following is just one of many cases: http://social.technet.microsoft.com/wiki/contents/articles/28875.dependency-injection-in-asp-net-vnext.aspx But what happens if I want to do the following: var todoRepository...

Using HttpClient in ASP.NET 5 app

asp.net,httpclient,asp.net-5
I am trying to build an app with ASP.NET 5 (aka vNext). I need to call a third-party REST-API. Traditionally, I would use HttpClient. However, I can't seem to get it to work. In my project.json file I have: "dependencies": { "Microsoft.Net.Http.Client": "1.0.0-*" } When I run dnu restore, I...

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

c#,.net,asp.net-5,roslyn,.net-core
I have a project using the new .net project format (dnx and project.json, currently using dnvm with mono-1.0.0-beta4, eventually want to use coreclr once they get dnu restore working on *NIX). One of the common problems that I have with .net/C# is the desire to create code at compile time....

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
I am creating a web api using mvc 6. now i am trying to get a element from my db. the key in this table is a string (email adress). i do not have acces to this database so i cant change the key of this table. Now when creating...

Using Routing to return a WebForms page

c#,webforms,asp.net-5,asp.net-routing,asp.net-mvc-6
If I have a simple Default.aspx WebForms page under Views/WebForms/Default.aspx, how do I configure the MVC routing to open the Default.aspx page at startup? I've tried reading some articles regarding the MVC 6 routing, but I don't think they're mentioning anything about incorporating WebForms routing with the new MVC 6....

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

msbuild,teamcity,asp.net-5,dnx
I'm trying to setup a CI server for a website that I'm developing, but I can't find any info regarding how to do it with the new ASP.NET 5.

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

nunit,resharper,asp.net-5
I am developing an asp.net 5 application targeting dnx451. The asp.net 5 project relies some libraries with unit-tests written for nunit 2.x. So the reasonable choice for me is to use nunit for testing the asp.net 5 project. When I running the unit test in ReSharper , the ReSharper says...

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
From the wiki for the main "aspnet" GitHub repo: "The DNX is an SDK containing all of the bits needed to build and run an application, including the CLR in the case of Core CLR. It can be bin deployed with your application...". I'm a bit confused on what this...

Unable to use Serilog in Controller in asp.net 5

asp.net-5,serilog
How can I use Serilog from Controller itself? I have added this in my Configure method in Startup class : var serilog = new Serilog.LoggerConfiguration().MinimumLevel.Debug().WriteTo.File("C:/Temp/log.txt"); logFact.AddSerilog(serilog); I also tried something like this: public PeopleController(ILoggerFactory logFact) { _loger = logFact.CreateLogger<PeopleController>(); } And after that in action method I wanted to call...

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

c#,asp.net-5,asp.net-mvc-6
does anyone know how to pass a URL as a query string parameter and then get the URl in HttpGet method as a parameter ?

How to properly read nested configuration values from config.json in ASP.NET5?

c#,asp.net,asp.net-5,config.json
I was following some examples for ASP.NET 5 and I got stumbled with how to properly read "nested" configuration values (if that is the proper term). Here is relevant portion of config.json: { "ApplicationName" : "OwNextApp", "AppSettings": { "SiteTitle": "OwNext" }, } And relevant portion of HomeController.cs: public IActionResult About()...

asp.net 5 web application with websockets on Windows 7

websocket,signalr,asp.net-5
I have a relatively simple web application that I am currently porting to asp.net 5. The current version runs under IIS on some Windows 7 and Server 2008 machines. With the next version of my software I would like to connect a C++ client via SignalR to the web application....

How to Edit and Continue in ASP.Net MVC 6

c#,asp.net-5,visual-studio-2015,asp.net-mvc-6
Back in the days using older versions of Visual Studio and ASP.NET was possible to edit the code while you were debugging it (even with some limitations). How can I enable edit and continue using ASP.Net/VNext (MVC 6) with VS 2015 RC. This feature is available? The message that I...

Deploy MVC 6 app in IIS

asp.net-5,visual-studio-2015,asp.net-mvc-6
I'm using Visual Studio Express 2015RC and I created a simple MVC 6 application, but when I try to publish it I don't see the option to deploy it to IIS, I see the options Microsoft Azure Web App, Import and File System, I tried the File System but It...

SignalR, ASP.NET 5 and CORS

signalr,cors,asp.net-5
I'm trying to use SignalR with my MVC6 application, but I encounter problem with CORS. First : If I host my index.html file on http://localhost:1234/index.html (same as my web app) it's working. But when I host it elsewhere (for example in file:///C:/Users/me/Documents/index.html), I have this error : No 'Access-Control-Allow-Origin' header...

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

asp.net-mvc,asp.net-5
When i try to add a migration, "k" gives me the following error: k : System.Exception: Unable to locate project.json At line:1 char:1 + k web + ~~~~~ + CategoryInfo : NotSpecified: (System.Exceptio...te project.json:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError bij Microsoft.Framework.Runtime.DefaultHost.Initialize(DefaultHostOptions options, IServiceProvider hostServices) bij Microsoft.Framework.Runtime.DefaultHost..ctor(DefaultHostOptions options, IService Provider...

Why is the EmbeddedFileProvider not hierarchical?

asp.net-5
Today, I was attempting to use the EmbeddedFileProvider as a read-only fake for an IFileProvider. Unfortunately, getting "directory" contents proved impossible because of the following lines of code: // Non-hierarchal. if (!subpath.Equals(string.Empty)) { return new NotFoundDirectoryContents(); } Given that embedded files (at least, with beta 4) retain their folder structure...

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

dependency-injection,asp.net-5
Is there are possibility to instantiate class using ASP.NET 5 default Dependency Injection when that class have constructor with parameters? I would like to register Repository with constructor that accepts connection_string. UPDATE I think that I can rephrase the question. I would like to specify which constructor will be called...

Unable to add any nuget dependency with ASP.NET 5

nuget,asp.net-5,visual-studio-2015
I've just downloaded Visual Studio Enterprise 2015 RC and I'm trying to create a simple ASP.NET 5 application. But each time i'm modifying the project.json to add a dependency, I always have an error. For example, when adding a dependency to Newtonsoft.Json I have : "Dependency Newtonsoft.Json >= 6.0.8 could...

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

asp.net,asp.net-5,roslyn
We're muddling thru doing authentication in ASP.NET 5. In this security sample, we see this type of thing: app.Run(async context => { var types = context.Authentication.GetAuthenticationSchemes(); } Initial Problem In our project, however, the HttpContext did not have an Authentication property and we would receive the following error: Microsoft.Framework.Runtime.Roslyn.RoslynCompilationException: C:\myApp\Startup.cs(71,46):...

CORS for static HTML in vNext

cors,asp.net-5,asp.net-mvc-6
I have an MVC6 site running in Visual Studio 2015 RC I've got some static HTML files I want to serve to another website. I want to add CORS support (without having to add a controller and add CORS that way). Does anyone know how to do this please?...

TagHelper for passing route values as part of a link

asp.net-5,asp.net-mvc-6,tag-helpers
When specifying asp-controller and asp-action on a link, what's the syntax for also passing an id attribute? E.g. If I wanted to link to the edit URL for a given object, the required URL would be /user/edit/5 for example. Is there a method to achieve this using TagHelpers, or do...

.vs\config\applicationhost.config in source control

iis-express,asp.net-5,visual-studio-2015
Visual Studio 2015 adds a file named .vs\config\applicationhost.config to the root of a solution when an ASP.NET Web application project is created. Should this file be checked in to source control or should it be ignored (so that each user will have their own local copy)?...

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
I am building a throwaway application in MVC 6 and experimenting with different architectures for dependencies. The problem I am facing is how to create a custom 'MyAppContext' object specific to the Application. This would require some information from the HttpContext and some information from the database, and will be...

Public Files in ASP.NET 5

asp.net,asp.net-5
I'm dipping my toes into ASP.NET 5 (vNext). To do that, I downloaded Visual Studio 2015 RC. I created a new ASP.NET Web Application. Then, in the next dialog I chose "Empty". From there I added a basic controller and a basic view. I want to add bower and reference...

Get injected IOptions

asp.net-5
I'm trying to build my first ASP.NET vNext web application and the problem I've faced is that I can't get IOptions<AppSettings> injected to my Startup.Configure() method. The odd thing is that MVC sample site which was generated by VS2015 does the same steps but the same injecting works! Both projects...

MVC 6 OpenIdConnect

asp.net-5,asp.net-mvc-6,openid-connect
Good afternoon everyone, I am currently running into multiple issues migrating my MVC application from beta 3 to 4 - one of these has to do with OpenIdConnect to Windows Azure for authentication. When I go to a page that has an Authorize attribute, the page stops processing and sits...

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
I have got a project with two web apps. One of them is only for reference in the base app. The project runs okay in visual studio. I am trying to publish it in local file system and then copy it across to the windows server 2008. Below is the...

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

asp.net-5,visual-studio-2015,dnx,.net-5.0
The default location of project.json is in the root folder of the asp.net project folder. I dislike having configuration files jumbled in with classes and would prefer to move project.json (and other configuration and startup elements) to a Configuration folder. I moved project.json (in visual studio solution explorer) to a...

Kestrel Running which framework?

azure,asp.net-5,dnx,dnvm,.net-5.0
I have a new ASP.NET 5 project and setup the project.json as below; "frameworks": { "dnx451": { "dependencies": { "ExternalLibrary": "1.3.0" } }, "dnxcore50": {} } I'm running the project through Kestrel with the default command defined in project.json. "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5001" Everything works fine. The project...

How to install DNX Secret Manager in Mac OSX

osx,asp.net-5,dnx
I'm developing with ASP.NET5 on Mac OS X. I want to implement OAuth and use Secret Manager to store my secret configuration, so I'm following this DNXSecret Configuration page. https://github.com/aspnet/Home/wiki/DNX-Secret-Configuration But, after following the instructions, I couldn't successfully install user-secret command to my Mac, and I'm pretty much stuck. As...

db.database.ExecuteSQLCommand equivalent in EF 7

entity-framework,asp.net-5,asp.net-mvc-6,entity-framework-7
Whats the equivalent of db.Database.ExecuteSqlCommand(Sql.ToString()); in Entity Framework 7? I saw .FromSQL() in beta 4, but haven't seen anything to the above....

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

osx,asp.net-5,kestrel
I'm building a simple WebApi in asp.net vnext on a Mac. I've followed the example set in this tutorial but I'm having a problem where the response codes I set in my controller methods are being overridden Take this method in my CrudController: [HttpPost] public void Post([FromBody]CrudObject crudObject) { var...

MVC 6 install as a windows service

asp.net-5,asp.net-mvc-6,dnx
I have created a simple MVC 6 app and have included the Microsoft.AspNet.WebListener library so I can host outside of IIS. From project.json: "dependencies": { "Microsoft.AspNet.Server.WebListener": "1.0.0-beta4", "Microsoft.AspNet.Mvc": "6.0.0-beta4" }, "commands": { "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000" } When I publish this I can run the web.cmd file and...

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

c#,asp.net-5,vs-2015-preview
I am creating a Simple application in ASP.NET 5 Console in VS2015 CTP. For the below line of code // Wait for user input Console.ReadKey(); I am getting error 'Console' does not contain a definition for 'ReadKey'. Also i am getting a Suggestion as ASP.Net 5.0-Available ASP.NET Core 5.0- Not...

Correct way to get instance of IHostingServices

c#,asp.net,asp.net-5
In ASP.NET 5 core there is an interface, IHostingEnvironment, but looking at the samples and source code for ASP.NET there are 3 different ways to obtain an instance. Using an attribute... [FromServices] public IHostingEnvironment HostingEnvironment { get; set; } As an argument passed via the configure method in the Startup...

Access connection strings

azure-web-sites,asp.net-5
In ASP.NET 5, how do we programmatically access an Azure Web App's connection strings? I've been able to retrieve the TEST_APP_SETTINGS value but not the TestConnString one. Here is what I have tried: services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings")); I'm afraid that AppSettings doesn't exist. I've also done this and the app settings show up...

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

cloudfoundry,asp.net-5,bluemix
I'm trying to deploy a aspnet5 Project (Template vNext WebApplication from Visual Studio) to Bluemix CF Service (Asp.net). Yet it's not possible and fails with: OUT FAILED: Writing Release YML failed, 746: unexpected token at '?{ OUT "webroot": "wwwroot", OUT "dependencies": { OUT "Microsoft.AspNet.Diagnostics": "1.0.0-beta4", OUT "Microsoft.AspNet.Mvc": "6.0.0-beta4", OUT "Microsoft.AspNet.Mvc.TagHelpers":...

Configure the authorization server endpoint

c#,asp.net,oauth,asp.net-identity,asp.net-5
Question How do we use a bearer token with ASP.NET 5 using a username and password flow? For our scenario, we want to let a user register and login using AJAX calls without needing to use an external login. To do this, we need to have an authorization server endpoint....

Web API Authentication in ASP.NET 5

c#,asp.net,authentication,web-api,asp.net-5
I've been studying ASP.NET 5 for some time now and there is something I'm yet confused. To implement authentication in Web API 2 what I used to do was basically use the OWIN OAuth Authentication Server Middleware. It was simple to use, I could configure just what I needed and...