asp.net-core-mvc

MVC 6 Windows Server 2012 R2 IIS 8.5 - Error: Unable to load application or execute command 'Microsoft.AspNet.Server.Kestrel'

余生长醉 提交于 2019-12-13 21:43:15
问题 When trying to deploy a MVC 6/ASP.NET 5 application to IIS I get the error Error: Unable to load application or execute command 'Microsoft.AspNet.Server.Kestrel'. Available commands: web, ef. in the stdout log file. I published the application using Visual Studio 2015 and it runs ok if I call web.cmd directly in a command prompt. My project.json file looks like { "userSecretsId": "aspnet5-H3CustomerPortal-2b9cfc76-487a-41dc-a29f- c81e45251c25", "version": "1.0.0-*", "compilationOptions": {

jQuery: Result of script gets deleted after execution - removeData() running on the background?

蹲街弑〆低调 提交于 2019-12-13 20:31:56
问题 I have a modal window used to update or add a new object Store . This modal has a cascading dropdownlist for two properties: Department and District . How should it work: We first identify if we are in the situation of creating or updating a Store . In case is a new Store the modal opens and using jQuery we present a default value for the District dropdownlists (since no Department has been chosen yet). <script type="text/javascript"> var wasclicked = 0; var $this = this; $(document).ready

For data validation, where to add Html.RenderPartialAsync(“_ValidationScriptsPartial”)?

不想你离开。 提交于 2019-12-13 20:23:29
问题 In my ASP.NET Core 1.1.1 app the model validation is not working. I've noticed that some of the default views (such as login.cshtml , Register.cshtml that were created by VS2017 when the app was created) have the following code at the end. But these default views are in fact partial views. My Views are not partial views, should the following be added to end of my views as well? Or what should I be adding to the end of my views that are not partial views: @section Scripts { @{ await Html

MVC6 Prevent Redirect on unauthorized

谁说胖子不能爱 提交于 2019-12-13 19:25:07
问题 I'm developing an ASP.NET MVC 6 Web API app, with AngularJs frontend. When I leave a session to decade, or I'm trying to call a Web API action unauthorized, I expect to receive a 401 status code. Instead, I get a 302, and tries to redirect to the default path for login ("/Account/Login"). So I need to handle this in Angular. From other forum posts here and googling I found that some people resolved their problems using in startup.cs: services.Configure<CookieAuthenticationOptions>(options =>

aspnet 5 (MVC6) Windows Auth + roles + Authorize attribute

自闭症网瘾萝莉.ら 提交于 2019-12-13 19:24:25
问题 I have an app that uses Windows Auth on aspnet 5 MVC 6 (obv using IIS + IISPlatformHandler) How can I restrict access to a controller by AD group? I have tried doing something like the following, but it won't work :( When I look at my user claims I see many groups and claims that look like SID's ex. {S-1-5-4} [Authorize(Roles = "DOMAIN\\GROUP") public class myController : Controller{...} 回答1: As of July 2016, I find the following now works with .NET Core RTM (WebAPI): [Authorize(Roles = @

How to replace MVC HomeController/Index redirects with RazorPages routings?

。_饼干妹妹 提交于 2019-12-13 19:04:50
问题 I'm migrating from ASP MVC Classic to ASP Razor Pages. Only one controller left to "migrate": HomeController public class HomeController : Controller { UserManager<WebUser> _userManager; public HomeController(UserManager<WebUser> _userManager) { this._userManager = _userManager; } [Authorize] public async Task<IActionResult> Index() { var user = await _userManager.GetUserAsync(User); if (user == null) { return RedirectToPage("/Account/Login", new { area = "WebUserIdentity" }); } return

Akka.net asp.net 5 mvc 6 configuration for Hocon

假装没事ソ 提交于 2019-12-13 16:12:47
问题 I am currently trying to use akka.net but the configuration they use HOCON is a different syntax from the json syntax normally used in app.json when configuring our app. Does anyone know how to use HOCON with the current app.json configuration? 回答1: I use ConfigurationFactory.FromObject and some classes that has the properties that I'm interested in to read the akka-config from appsettings. var config = ConfigurationFactory.FromObject(new { akka = configuration.GetSection("Akka").Get

Return image from file system

回眸只為那壹抹淺笑 提交于 2019-12-13 15:27:14
问题 There is successfully uploaded image in file system and I want to get access to it. So, I have written GET -method [HttpGet] public ActionResult Get(string id) { var path = $@"d:\smth\upload\{id}.jpeg"; return File(path, "image/jpeg"); } I'm totally sure that there is the file in required path with required name, but anytime a try to create File(path, "image/jpeg") I get Could no find file exception. Seems like i dont have access to folders outside wwwroot . Maybe I have missed something

web.config in ASP.NET 5 MVC 6

白昼怎懂夜的黑 提交于 2019-12-13 15:08:30
问题 I have a WCF .dll that loads configuration from web.config file. I'm using that dll in asp.net 5 application, when I try to call a function from dll, I'm getting exception: Could not find default endpoint element that references contract 'WebService.MyWebService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element. The

ASP NET 5 Localization using View components in a separate assembly

放肆的年华 提交于 2019-12-13 14:27:12
问题 I have a "Class Library" project with some "ViewComponents" on it and I already made them work on my "MVC 6 Web app" (thanks to this question) but now I'm trying to add language resources (localization) to my "ViewComponents". Any suggestion on how this should be done?. I already added the necesary lines to the startup file on my "MVC 6 Web app": startup.cs [...] services.AddMvc() .AddViewLocalization(options => options.ResourcesPath = "Resources"); [...] app.UseRequestLocalization(new