FAQ Database Discussion Community


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 5: Bind attribute with Include parameter - include is not a valid named attribute argument

attributes,model-binding,asp.net-5,asp.net-mvc-6
I write code from the article and and there is: public IActionResult Create([Bind(Include="Imie,Nazwisko,Stanowisko,Wiek")] Pracownik pracownik) { blablablab } I want to compile but it shows error. include is not a valid named attribute argument. But in the internet I saw a code similar to my code. Someone explain to me...

Problems publishing asp vnext website on IIS 8

iis,asp.net-5,visual-studio-2015,asp.net-mvc-6
I've followed all instructions from this topic and it still doesn't work . How to configure an MVC6 app to work on IIS? If i enable Directory Browsing in IIS, I can see all files from wwwroot . If i disable it , I get this error : HTTP Error...

MVC One controller many Index view

asp.net-mvc,asp.net-mvc-6
I've searched many topics but I couldn't find answer for my question. I'm using MVC 6. I have following structure: > Controllers > AccountController > Views > Account Index.cshtml > MyReviews Index.cshtml The AccountController looks like: // // GET: /Account/Index [AllowAnonymous] //temp [HttpGet] public IActionResult Index() { return View(); }...

asp.net 5 mvc 6 loginUrl change path

asp.net-mvc-6
When creating a new project in VS 2015 WebApplication. How would you go about changing the Redirect LoginUrl Path when not Authorize'd I have created a new Area, where I have created a loginController. This loginController requires you are Authorize'd. But when trying to reach the pages, I am redirected...

Bundling and Minification in MVC 6

bundling-and-minification,asp.net-5,asp.net-mvc-6
It looks like Bundling and Minification are no longer built into MVC 6 since there is no more App_Start and Bundle.Config. Is this going to be the case after final release? I'm guessing Grunt should be used since that seems to be baked into Visual Studio 2015. UPDATE: It looks...

ActionLink (LinkText,Action,ControlName,AreaName,RoutesValue,html attribute)

asp.net,asp.net-mvc,routes,actionlink,asp.net-mvc-6
A bottom'd like code samples ActionLink (LinkText,Action,ControlName,AreaName,RoutesValue,html attribute) I looked at the sites do not have all of these together Thanks

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...

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...

Why using UseCookieAuthentication cause exception?

c#,asp.net,visual-studio-2015,asp.net-mvc-6
asp.net 5 mvc 6, visual studio 2015 RC Why is this code causes an exception when i run application in (debug/release) app.UseCookieAuthentication(options => { options.AuthenticationType = "Cookies"; options.LoginPath = new PathString("/Action/Login"); }); System.IO.FileNotFoundException Could not load file or assembly Microsoft.Framework.Logging.ILoggerFactory, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null or one of their dependencies. Can not...

Sessions can't store serialized objects?

asp.net-mvc-6
I'm trying to migrate a MVC3 Project to a MVC6, I've sorted out most of the obstacles but now I have a problem with sessions, I'm using "Microsoft.AspNet.Session": "1.0.0-beta4", and I can add strings and ints with no problem, but looks like I cannot add objects, only byte arrays (byte[]),...

ASP.NET 5 Adding MVC6 Unit Test Project

asp.net,asp.net-mvc-6
I'm trying to add Unit Test Project to a ASP.NET 5 Solution. I've added ASP.NET 5 class library project and referenced the required packaes in my project.json as below :- { "dependencies": { "xunit.runners": "1.0.0-alpha3", "Moq": "4.2.1502.911", "xunit": "2.0.0-rc4-build2924" }, "commands": { "test": "Xunit.KRunner" }, "frameworks": { "net451": { "dependencies":...

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...

Angular $http.post to a ASP MVC 6 Web Api

angularjs,post,asp.net-mvc-6
I'm trying to create a very basic login example using an angularjs client and an ASP MVC 6 beta 4 Web Api. The login call on angular controller side : function login() { vm.dataLoading = true; $http.post('/api/account/login', { model: { Email: vm.username, Password: vm.password, RememberMe: vm.rememberMe } }) .success(function (data)...

Access to Configuration object from Startup

c#,asp.net-mvc-6
I would like to access to the Active Directory from my company in many controllers from my ASP.NET vNext project, and I inserted the domain name into my config.json file, so I can access it from the Configuration class. I find it heavy to always instantiate a new Configuration object...

VS2013 Is Not Compatible With VS2015 Project Type

asp.net-mvc,visual-studio-2013,asp.net-mvc-6
I am using Visual Studio 2013. But when i open the MVC project code in Github: https://github.com/betimer/Mvc I found that the solution was built on the new type (project contains: xxx.xproj + xxx.json) (I think they are VS 2015 types) Is there any way to let my VS 2013 compatible...

How to access HttpContext inside a unit test in ASP.NET 5 / MVC 6

asp.net,unit-testing,httpcontext,asp.net-mvc-6
Lets say I am setting a value on the http context in my middleware. For example HttpContext.User. How can test the http context in my unit test. Here is an example of what I am trying to do Middleware public class MyAuthMiddleware { private readonly RequestDelegate _next; public MyAuthMiddleware(RequestDelegate next)...

Getting the host name from a scoped service factory

dependency-injection,asp.net-5,asp.net-mvc-6
One of the services I'm creating needs the current host name as a parameter (different requests use different host names, which affects external resources used by my service): public class Foo { public Foo(string host) {...} } I'm registering it as scoped: public void ConfigureServices(IServiceCollection services) { services.AddScoped(s => new...

How do I create Constructor Subscription in vNext Dependency Injection

c#,asp.net-mvc,dependency-injection,asp.net-5,asp.net-mvc-6
I am experimenting with a throwaway vNext application. What I'm trying to do is create a dummy class called 'DataService' which will return some data, and then create objects which use DI to take an IDataService parameter as the constructor. So my IDataService/DataService definitions are: public interface IDataService { DateTime...

ASP.NET 5 MVC6 Custom CSS & Javascript placing convention

asp.net,asp.net-mvc-6
So I'm playing around with MVC6, and I've added bower.json & grunt.json, I've created my grunt tasks for generating my jQuery & bootstrap.css and its all sitting in the wwwroot folder as i expected. But what about things like my site.css & my main.js files, the files that i will...

Using System.Net.Mail in ASP NET MVC 6 project

asp.net-mvc-6,system.net.mail
I have trouble creating a simple mock mail sender within an ASP NET 5 project. Here the method : public static Task SendMail(string Email, string Subject, string Body) { SmtpClient client = new SmtpClient(); client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; client.PickupDirectoryLocation = "C:\\TMP"; MailAddress from = new MailAddress("[email protected]", "Jane " + (char)0xD8 +...

MVC 6 HttpPostedFileBase?

asp.net-mvc-6,httppostedfilebase
I am attempting to upload an image using MVC 6; however, I am not able to find the class HttpPostedFileBase. I have checked the GitHub and did not have any luck. Does anyone know the correct way to upload a file in MVC6? Truly appreciated, Steven M....

How can I retrieve AppSettings configuration back in Asp.Net MVC 6?

c#,dependency-injection,asp.net-mvc-6,appsettings
Assuming that I am using the new DepencyInjection framework to configure my classes and dependencies in the new ASP.Net/vNext. How can I use, How can I get my pre-defined configuration settings? public void ConfigureServices(IServiceCollection services) { // Add Application settings to the services container. services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings")); // Add EF services to...

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...

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...

Increasing max. request length in asp.net 5 (vNext)

asp.net,iis,iis-express,asp.net-5,asp.net-mvc-6
My problem is similar to the one described here: Maximum request length exceeded Since there is no web.config file in asp.net 5 (it is replaced by 'config.json' as far as I understand), how can one do this? Also, if anyone found any documentation on the new 'config.json' file, I would...

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...

asp.net 5 mvc 6 model issue

asp.net-mvc,asp.net-mvc-6
I am trying to list some data from a news section. I have two tables. News and NewsCategory This is my model classes public class News { public int NewsId { get; set; } public string Name { get; set; } public int NewsCategoryId { get; set; } public virtual...

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...

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...

Include several references on the second level

asp.net-mvc-6,entity-framework-7
Assume we have this model : public class Tiers { public List<Contact> Contacts { get; set; } } and public class Contact { public int Id { get; set; } public Tiers Tiers { get; set; } public Titre Titre { get; set; } public TypeContact TypeContact { get; set;...

How to inject DbContext in MVC 6 using default dependency injection?

asp.net-5,asp.net-mvc-6
Can you please tell me how to inject a dbContext using the default dependency injection in MVC 6? Do I just need to create an interface and add it in the Startup.cs as below? services.AddTransient<IMyDb, MyDb>();...

Publishing MVC 6 site with Visual Studio 2015 CTP 6 to IIS

iis-8,asp.net-5,visual-studio-2015,asp.net-mvc-6
I am trying to publish a site to IIS that I am developing using MVC6 (beta 3) with Visual Studio 2015 (CTP 6). I have publishing set to target the x64 version of KRE. All goes well with the publishing, and no errors are reported, but I cannot get the...

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?...

Can't send parameters through POST on asp.net vNext app. (beta 3) (MV6, mono, EF7, OSX)

asp.net,osx,post,mono,asp.net-mvc-6
I hope someone can help me with this... I'm working on osx on a new small project and "getting to know" the new vNext with MV6 and Entity Framework 7, with mono, kestrel, and using sublime text for the coding... I have a very simple form: <div class="login-form-outer"> @using (Html.BeginForm("Login2",...

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...

HTTP Error 403.14 in ASP.NET5 MVC6

asp.net-mvc-6,vs-2015-preview
I am just exploring ASP.NET 5 MVC 6 web app with new Visual Studio Community 2015 RC. DotNet framework 4.6. I've added reference Microsoft.AspNet.MVC (6.0.0-beta4) from nuget. Then created Models,Views & Controllers directory. Also added HomeController and a view. Here is my Startup.cs- public class Startup { public void ConfigureServices(IServiceCollection...

Rendering Views from external assemblies in MVC6

c#,asp.net-mvc-6
I'm able to load controllers from external assemblies in MVC6, due to how it finds controllers. But I am unable to render a view that is also in that assembly, as it says it can not be found. The assembly that contains the views and controllers looks as so: The...

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...

Unable to use my HtmlHelper in views

c#,asp.net-5,asp.net-mvc-6
Trying to use my mvc5 project in a new asp.net vNext project, I am unable to use my HtmlHelper that automatically format a textbox. Here is my helper extension class : namespace MyNamespace.Helpers { public static class YokoHelper { public static HtmlString YokoTextBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, string...

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...

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 do I get client IP address in ASP.NET 5 MVC 6?

asp.net-5,asp.net-mvc-6
Can you please let me know how to get client IP address in ASP.NET when using MVC 6. Request.ServerVariables["REMOTE_ADDR"] does not work.

Use Office Interop on ASP.net MVC6 website

com,ms-word,office-interop,asp.net-mvc-6
I want to generate word documents from my ASP.net MVC 6 website. I've implemented several ways to generate a document in a POC : DocX, NetOffice, OpenXml, COM Interop objects. I was seduced by it. I made a Console App to test and it works. But, with ASP.net MVC6, we...

Dependency injection (DI) in ASP.Net MVC 6

c#,asp.net-mvc,dependency-injection,asp.net-mvc-6
i was reading a write up on easily dependency injection in ASP.Net MVC 6 from this url http://weblogs.asp.net/scottgu/introducing-asp-net-5 they show how very easily we can inject dependency into project 1st one namespace WebApplication1 { public class TimeService { public TimeService() { Ticks = DateTime.Now.Ticks.ToString(); } public String Ticks { get;...

@helper directive no longer works out of the box in ASP.NET5 MVC6 beta4.

razor,asp.net-5,asp.net-mvc-6
Since I updated my ASP.NET5 project to beta4 (the one included with Visual Studio 2015 RC), any of my Razor views where I use a helper, such as: @helper foo() { <h2>Bar</h2> } results in the following error: error CS0103: The name 'helper' does not exist in the current context....

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...

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>...

Request.PhysicalApplicationPath in ASP-MVC 6?

asp.net-mvc,asp.net-mvc-6
In MVC 6 the Request object doesn't have the Request.PhysicalApplicationPath method, how can I get the executing path then? Thank you....

ASP.NET MVC 6 (vNext) not properly linking to files

asp.net,asp.net-mvc,asp.net-mvc-6
I'm trying to run the ASP.NET 5 MVC 6 sample "HelloMVC" project, with a custom CSS file. I place my .css files in the wwwroot folder, let's say in a styles folder. I then link to it in my _Layout.cshtml with <link rel="stylesheet" href="~/styles/mystyle.css" /> However, the style doesn't get...

ViewComponents in Areas

asp.net-mvc-6
I may be doing this wrong (I cannot find any documentation on how to do it any other way). When you create a ViewComponent in an Area, the Search paths are incorrect: namespace HelloWorld { [Area("Test")] public class HelloViewComponent : ViewComponent { public IViewComponentResult Invoke() { return View(); } }...

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 get the current logged in user Id ASP.NET MVC6

asp.net,asp.net-identity,asp.net-mvc-6
I've done this before with MVC5 using User.Identity.GetUserId() but that doesn't seem to work here. The User.Identity doesnt have the GetUserId() method I am using Microsoft.AspNet.Identity...

ASP.NET MVC 6 default debugging launch URL

asp.net-mvc-6
When using the new Visual Studio 2015 RC ASP.NET 5.0 Web API template the default debugging start up URL is somehow set to api/values. Where is this default configured and how do I change it?

Anybody's had any luck with asp.net MVC 6's new html markup?

asp.net-mvc,razor,asp.net-5,asp.net-mvc-6
It seems not many people are testing asp.net vNext MVC 6 as I can't dig out much resource. I am interested, so I have been testing it these days. In Scott's article, he says that So instead of writing this: @Html.ValidationSummary(true, "", new { @class = "text-danger" }) <div class="form-group">...

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 ?

Visual Studio and KVM version mismatch

visual-studio,kvm,asp.net-mvc-6,kruntime
Everything was working fine until I performed kvm upgrade on the console. It seems that Visual Studio is working from C:\Program Files (x86)\Microsoft Web Tools and KVM is working from c:\users\username\.k It seems as though Visual Studio provided the K runtime without KVM. Because there is no KVM script in...

ASP.NET 5 vNext Forms Having Anti Forgery Tokens Added

angularjs,asp.net-mvc-6
I'm experiencing an issue where a simple form tag is having an action and method attribute added to it. Also added are some hidden input fields for what I am guessing is anti-forgery. Here is the html I'm adding in the Razor View: <form>test</form> And here's what's being rendered: <form...

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...

How to use soap web services in MVC 6 using asp.net 5?

asp.net-5,asp.net-mvc-6
I have got some classes generated by wsdl for soap web services. These are using namespace System.Web.Services. How can I use them in MVC6, asp.net 5 ?

Unable to utilize UrlHelper

asp.net,asp.net-mvc-6
I'm currently trying to do something that was dead simple and straight forward in ASP.NET 4 however this ins't the case now in ASP.NET 5. Previously to use the UrlHelper it was dead simple: var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext); However I can't for the life of me wrap my head...

Future plans to consider for asp.net mvc 5.2 web application, with releasing asp.net mvc6 (vnext)

asp.net,asp.net-mvc,asp.net-mvc-5,asp.net-mvc-6,asp.net-mvc-5.2
I need to get any ideas of how i should be managing our previous asp.net MVC 5.2 web application.. now i am using asp.net mvc-5.2 with entity framework 6.0. and i want to start phase-2 for some of these projects. so should i consider upgrading my mvc 5.2 to be...

File IO Close() method error in ASP.NET MVC 6

asp.net-mvc,asp.net-mvc-6
I am doing a simple file IO in MVC6. I have added System.IO NuGet package. However, it gives me compile time error. VS IDE doesn't show any red mark when I type the code. The Close() method also appears in intellisense. Please help! My Code StreamWriter writer = System.IO.File.CreateText("some_valid_path"); writer.WriteLine("test");...

Syntactic sugar in Web Api - how to omit [FromBody]

c#,asp.net-mvc-6,syntactic-sugar
Is it possible to omit writing [FromBody]? [HttpPost] public string SomeMethod([FromBody]SomeModel model) { return "OK"; } Should I apply some global attribute? How to achieve this?...

Migrate MVC 5 to MVC 6

asp.net-5,asp.net-mvc-6
I just wanted to know if there is any auto migration tool available to update from MVC5 to MVC6. As they made some changed, like instead of Global.asax, there is a startup class. I am using URL Rewriting and using Global.asax Application methods to achieve it. Any help ?...

Is controller scaffolding missing in MVC 6?

c#,asp.net-mvc-6,asp.net-mvc-scaffolding,vs-2015-preview
When creating controller in MVC 6 I don't see the scaffolding for creating controller methods? Will they be missing or in the production release?

Setup MongoDB in VNext

asp.net-mvc,mongodb,visual-studio-2015,asp.net-mvc-6
I have some issues using MongoDB in the a VNext project Link to github with code https://github.com/Mech0z/MagicDraftStatistics/tree/NewFeatures If I use this package mongocsharpdriver Which is now obsolete, I get Warning 'MongoClientExtensions.GetServer(MongoClient)' is obsolete: 'Use the new API instead.' and 6 of these Error The type or namespace name 'MongoServer' could...

ASP.NET vNext AntiForgeryToken

asp.net-mvc-6,antiforgerytoken
Is @Html.AntiForgeryToken() still required in ASP.NET .NET4.6 vNext? The form decorations have changed to <form asp-controller="Account" asp-action="Login" asp-route-returnurl="@ViewBag.ReturnUrl" method="post" class="form-horizontal" role="form"> From this - @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "", role = "form" })) And no longer include this @Html.AntiForgeryToken() The...

TagHelper specify valid attributes

c#,asp.net,asp.net-mvc,asp.net-mvc-6,tag-helpers
I am playing around with creating a custom tag helper in MVC 6 / ASP.Net vNext - the taghelper works fine, however is there a way to specify valid asp- attributes to use with the tag so they appear in intellisense? For example, I want asp-ajax and asp-onsuccess to come...

Add namespace to all views in ASP.NET MVC 6

asp.net-5,asp.net-mvc-6
I’m using MVC 6 and would like to be able to access a particular namespace globally from all of my Razor views. In MVC 5 this was fairly simple; I’d just add the following code to my ~/views/web.config file: <system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="System.Web.Mvc.WebViewPage"> <namespaces>...

NET 5 MVC 6 - Publishing to Azure Websites ERROR_COULD_NOT_FIND_APPROOT_FOLDER

azure,asp.net-mvc-6
Just trying to publish a mvc 6 default template (web api) project to azure (importing publishing profile from the publishing wizard, info is correct but on preview or publish I receive : ERROR_COULD_NOT_FIND_APPROOT_FOLDER searching for the error on google gives me 0 results. also the link provided by microsoft doesn't...

Where are @Json.Encode or @Json.Decode methods in MVC 6?

asp.net-mvc,asp.net-mvc-6
What is equivalent of MVC5's @Json.Encode method in MVC6? In MVC5 we can access those methods in views. But I can't find any methods which I can access from MVC 6 views. I don't want to write a helper method if there is already a built in feature in MVC6....

What are asp.net vNext features? [closed]

asp.net,asp.net-mvc-6
What is asp.net vNext? what are the new features included in vNext?Is it similar to asp.net-mvc-6? When will it be released?

Getting Absolute URL's using ASP.NET MVC 6

c#,asp.net,.net,asp.net-mvc,asp.net-mvc-6
In MVC 5, I had the following extension methods to generate absolute URL's, instead of relative ones: public static class UrlHelperExtensions { public static string AbsoluteAction( this UrlHelper url, string actionName, string controllerName, object routeValues = null) { string scheme = url.RequestContext.HttpContext.Request.Url.Scheme; return url.Action(actionName, controllerName, routeValues, scheme); } public static...

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....

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 get the details of an Error 500 for an Azure Web App?

azure-web-sites,asp.net-mvc-6
I have an MVC 6 site that has been deployed as an Azure Web App. I have enabled all tracing / diagnostic options in Visual Studio using Server Explorer. I am trying to do remote debugging, but I am only seeing an Error 500 on my browser, and not finding...

Publish to Azure fails with “ Unrecognized link extension 'contentLibExtension'” Error

azure,webdeploy,asp.net-mvc-6,vs-2015-preview
I am trying to publish ASP.NET MVC 6 App to Azure with Visual Studio 2015 CTP. And getting the following error Publishing with publish method [MSDeploy] Calling msdeploy with the command: ["C:\Program Files (x86)\IIS\Microsoft Web Deploy\msdeploy.exe" -source:IisApp='C:\Users\*****\AppData\Local\Temp\AspNetPublish\NgCalendar-28\wwwroot' -dest:IisApp='ngcalendar',ComputerName='https://ngcalendar.scm.azurewebsites.net/msdeploy.axd',UserName='$ngcalendar',Password='{PASSWORD-REMOVED-FROM-LOG}',IncludeAcls='False',AuthType='Basic'...

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 :...

ASP.NET 5 kre-version when deploying to Azure via BitBucket

c#,azure,bitbucket,asp.net-5,asp.net-mvc-6
I'm using new ASP.NET 5 and I've faced a problem. I have ASP.NET MVC 6 application. Source code I keep on BitBucket and Azure is my hosting. I linked BitBucket with Azure such that on every push, deploy is launched. Everything was working great until I updated KRE version to...

ASP.NET 6 get RazorViewEngineOptions from app.ApplicationServices.GetService

c#,asp.net,asp.net-mvc-6
How to get RazorViewEngineOptions from app.ApplicationServices.GetService? I am using ASP.NET MVC 6 if that matters at all. In my 'Startup.cs' I have: public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory) { var razorViewEngineOptions = app.ApplicationServices.GetService<????>(); } What I want to know is what service do I need to fetch (shown...

EF7: Foreign Keys are not generated when adding to Database Context

c#,linq,asp.net-mvc-6,entity-framework-7
I'm currently using Entity Framework 7.0.0-beta3 and am trying to create a many-to-many relationship between two tables. For that I'm using the syntax from The answer of this question, minus the ICollections: public class Permissions { public Guid PermissionId { get; set; } public string Name { get; set; }...

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...

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...

Global Error Logging in ASP.Net MVC 6

asp.net,asp.net-web-api,asp.net-mvc-6
I'm testing out an MVC 6 Web Api and wanted to implement logging into a global error handler. Just guaranteeing no errors get out of the system without being logged. I created an ExceptionFilterAttribute and added it globally in the startup: public class AppExceptionFilterAttribute : ExceptionFilterAttribute { public override void...

How and Where to tell if a ViewComponent has been invoked x times in a view?

asp.net-mvc-6
I have a ViewComponent that I need to invoke twice only! How and where can I tell the invokations count? Currently I can use a session but I dislike using session in mvc apps! How may I achieve this? namespace Partials.Components { public class MyComponent : ViewComponent { public IViewComponentResult...

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...

ASP.NET 5 / MVC 6 Ajax post Model to Controller

c#,ajax,asp.net-5,asp.net-mvc-6
In my ASP.NET 5 MVC 6 application, I want to post with Ajax some data to my controller. I already done this with ASP.NET MVC 5 and I tested the exact same code in an blank ASP.NET MVC 5 project and it worked, but with the new version I can't...

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...

ASP.NET vNext - MissingMethodException: Method not found: Microsoft.CodeAnalysis.Diagnostic> EmitResult.get_Diagnostics()'

c#,.net,asp.net-mvc-6,vs-2015-preview,dnvm
I upgraded this morning to VS2015 RC, and I created a new project using the ASP.NET 5 Template - Web Site. I have an error that I am not able to solve: An unhandled exception occurred while processing the request. MissingMethodException: Method not found: 'System .Collections.Immutable.ImmutableArray`1 Microsoft.CodeAnalysis.Emit.EmitResult.get_Diagnostics()'. Microsoft.AspNet.Mvc.Razor.RoslynCompilationService.Compile(RelativeFileInfo fileInfo, String...

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?...

Debug Setting in .Net 5

asp.net-5,asp.net-mvc-6
With the debug setting gone in the web.config, what setting turns on and off debug and what is the equivalent (if any) for the following in .Net 5 (MVC 6 project)? #define DEBUG // ... #if DEBUG Console.WriteLine("Debug version"); #endif ...

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 =>...

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...

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...

Running a Script on Build (e.g. Gulp or Grunt)

asp.net-mvc-6
I have a project.json script for 'prepare' that runs a gulpfile to push my bower stuff into the wwwroot. Works great, except during dev I have to manually run it after I update the bower.json package. Any way to automate this during dev? I'd normally use a post-build script but...

How properly inject HttpContext in MVC6

asp.net-5,asp.net-mvc-6
My data service layer in my API required information that are of the request in the httpcontext, I read this question and they said that I should used the ActionContext instead of HttpContext.Current (discontinue in MVC6). The first way is to set the data inside the controller by overriding this...

OAuth Authorization Service in ASP.Net MVC 6

asp.net,oauth,asp.net-5,asp.net-mvc-6
In Web API 2, you used to be able to create an endpoint to issue a token by setting up an OAuth Authorization Server via middleware like below: //Set up our auth server options. var OAuthServerOptions = new OAuthAuthorizationServerOptions() { AllowInsecureHttp = true, TokenEndpointPath = new PathString("/token"), AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),...

VS 2015 CTP 6 Nuget Package Source

nuget,asp.net-5,asp.net-mvc-6
After installing VS 2015 CTP 6 it added the following url to Available Package Sources: https://api.nuget.org/v3/index.json and turned off the following: https://www.nuget.org/api/v2/ When it did this it stopped downloading all nuget packages. I switched it back to the old one and everything is working again. One thing I noticed is...

Returning JSON Errors from Asp.Net MVC 6 API

json,asp.net-web-api,asp.net-5,asp.net-mvc-6
I'm trying out building a web API with MVC 6. But when one of my controller methods throws an error, the content of the response is a really nicely formatted HTML page that would be very informative were this an MVC app. But since this is an API, I'd rather...