asp.net-core-mvc

IOptions<Applications> does not contain definition 'Options' in ASP.NET 5 Beta 8

故事扮演 提交于 2019-12-24 15:03:27
问题 Problem I am having trouble with upgrading my beta7 application to beta8. I orginally had over 50 errors, but I have basically gotten it down to two persistent errors remaining that I have been unable to resolve. One is with Options. Options Missing Error Here is the error: Error CS1061 'IOptions<ApplicationSettings>' does not contain a definition for 'Options' and no extension method 'Options' accepting a first argument of type 'IOptions<ApplicationSettings>' could be found (are you missing

MVC6 Connection Strings for SQL Server Express

二次信任 提交于 2019-12-24 14:44:38
问题 I was using MVC5 Entity Framework for a long time with connection string in web.config that look like this: <connectionStrings> <add name="GuestContext" connectionString="Data Source=DAVESQLSERVER\SQLEXPRESS;Initial Catalog=NexDec12;Integrated Security=False;User ID=sa;Password=changeME!;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False" providerName="System.Data.SqlClient" /> </connectionStrings> I am trying to figure out how to do this in the appsettings.json file. I am learning

How to overwrite one model property in ASP.Net core

天涯浪子 提交于 2019-12-24 13:47:53
问题 I have a model with say 10 properties. A, B, C and so on... Property A is an array. For each value in array I generate one tag like this: <div class="col-sm-10 row"> @foreach (var item in Model.A) { <div class="col-sm-1 right-buffer"> <a href="@item.Value"><i class="" aria-hidden="true">@item.Text</i></a> </div> } </div> When user clicks on some link I should redirect it to the same page, but with Some model property changed. For example: Current url: my/controller/someaction?name=Alex&age=20

appDomainCreationException in IIS Express using ASP.NET 5 beta7

会有一股神秘感。 提交于 2019-12-24 13:39:28
问题 After updating my app to beta7 I'm unable to run it from IIS Express using either view in browser or running it in the debugger it shows this exception in the browser but doesn't break on any exception in my code using the debugger: [Exception: Unexpected application failure. Status code '-2147024894'.] System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +361 [HttpException (0x80004005): Unexpected application

How to get the View to return the ID via a ViewModel to the controller?

纵然是瞬间 提交于 2019-12-24 12:29:58
问题 I currently have a view which returns an IEnumerable collection of Technicians via the TechnicianViewModel . The view model populates fine and displays the objects correctly. However, at the moment I need someone to point me in the right direction with regards to selecting a specific technician. If I was to click More Info on the technician, an [HttpGet] request would be initiated which would result in a queryString. And this is exactly what is against the requirements of this project.

Invoke same action for all urls in ASP.NET Core MVC

拟墨画扇 提交于 2019-12-24 12:23:02
问题 I am creating a single page app in the new ASP 5. How can I tell it to always server Home/Index no matter what (unless the request has wwwroot in the path)? More specifically, I would like something like this: app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "Home/Index/"); }); where first it searches the static files and then it if none are found, it just serves up Home/Index 回答1: How about a catch-all route? app.UseStaticFiles(); app.UseMvc(routes =>

Could not load type 'Microsoft.EntityFrameworkCore.Metadata.Internal.IEntityMaterializer' from assembly 'Microsoft.EntityFrameworkCore

吃可爱长大的小学妹 提交于 2019-12-24 11:32:44
问题 I am trying to connect my mvc core application to an existing ms access database roughly following this guide, but I am getting this error at startup: TypeLoadException: Could not load type 'Microsoft.EntityFrameworkCore.Metadata.Internal.IEntityMaterializer' from assembly 'Microsoft.EntityFrameworkCore, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. I would really appreciate any guidance at all as I'm a bit lost and there doesn't seem to be much information about this

How to Get HtmlHelper in MVC 6

风流意气都作罢 提交于 2019-12-24 11:09:33
问题 When using the MVC 6.0 beta1, I can see in the MVC source that there is a utility DefaultTemplatesUtilities.cs to GetHtmlHelper. But this HtmlHelper only returns formatted output that is setup in CreateViewEngine() method. How can I create a viewEngine so that the normal html is rendered. I need to get HtmlHelper through code and use it to generate some html. i.e. htmlHelper.EditorFor(model=>model.Property) 回答1: You can get HtmlHelper using Dependency Injection to your controller constructor.

Net Core MVC: Name Session does not exist in Current Context

耗尽温柔 提交于 2019-12-24 10:57:03
问题 I am receiving an error in the last line. How would I resolve this? Trying to convert Net 4.6.2 Project to MVC Net Core. Last Line Error: Name Session does not exist in Current Context. public class TransferPropertyOwnershipController : Controller { public ActionResult GetNewOwnerRecord(int ownerID, int propertyID) { OwnerManager ownerManager = new OwnerManager(); var newOwner = ownerManager.Get(ownerID, true); PropertyOwnerRoleViewModel newPropertyOwnerRoleViewModel = new

Could not load type 'Microsoft.AspNetCore.Mvc.Internal.IActionSelectorDecisionTreeProvider'

自作多情 提交于 2019-12-24 09:49:52
问题 I'm attempting to build the AutoOdataEF project with little success. I'm getting the following exception: Generated.OData.EF.API> Application startup exception: System.TypeLoadException: Could not load type 'Microsoft.AspNetCore.Mvc.Internal.IActionSelectorDecisionTreeProvider' from assembly 'Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Generated.OData.EF.API> at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig,