asp.net-mvc-5

ASP.NET Core map route to static file handler

戏子无情 提交于 2019-12-08 19:42:15
问题 I'm working on a ASP.NET Core website (previously named ASP.NET 5 / vNext) with Angular. In order for Angular to work I need to have a catch-all route: app.UseStaticFiles(); app.UseMvc(routes => { // Angular fallback route routes.MapRoute("angular", "{*url}", new { controller = "Home", action = "Index" }); }); I also have a few files/folders in wwwroot, like: wwwroot/app wwwroot/assets wwwroot/lib When any requests are made to these paths, for example http://example.com/assets/css/test.css ,

Is it possible to select an Action with AttributeRouting in .NET MVC based on the Media Type of the Accept header?

天大地大妈咪最大 提交于 2019-12-08 19:34:16
问题 I want to select an Action of my Controller based on the Media Type requested in the Accept header. For example, I have a resource called a subject. Its assigned route is: GET /subjects/{subjectId:int} Normally, the browser is requesting text/html , which is fine. The default Media Formatter handles this great. Now, I have custom logic I want to perform when this same route is accessed with an accept header specifying application/pdf as the accepted Media Type. I could create a custom Media

How do I use a Controller which is in a Class Library?

谁都会走 提交于 2019-12-08 19:19:02
问题 I have controllers in a class library but I can't work out how to get the main project to recognise them. The main project has a reference to my class library. Do I need to register them somewhere? I want to use both Controllers and ApiControllers. EDIT: Route config - unchanged from creating the project: public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/

Cookies AND Bearer Token in the same application

北城以北 提交于 2019-12-08 17:34:32
问题 So, here is my situation. I have a web application where Users register and manage/view the data that is automatically generated every time they have a doctor appointment. At the same time, this User data is exposed to any approved Client (third party app) via an API. Also, these Clients may feed data into the API. So my web is a central repository of data of the Users that other Clients can consume/feed. That's ok. Now, I want the User to create an account in my web application using Email

MVC5 with VB.NET: “BC30451: 'ViewData' is not declared.” when switching to Debug configuration

岁酱吖の 提交于 2019-12-08 17:30:29
问题 I have a MVC5 project that is currently set on the "Release Configuration" and it works 100%. However, as soon as I switch the project configuration from Release to Debug, then everything goes wrong... even if I switch it back to Release mode, everything is still broken. Only way I can get the project working again is to restore from a backup. Here are what is happening. Firstly, when running the project, I get the following error: BC30451: 'ViewData' is not declared. It may be inaccessible

Error with WebApi 2.0 RouteAttribute

社会主义新天地 提交于 2019-12-08 17:19:04
问题 Here's my Global.asax protected void Application_Start() { RegisterRoutes(); } private static void RegisterRoutes() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); GlobalConfiguration.Configure(x => x.MapHttpAttributeRoutes()); GlobalConfiguration.Configuration.EnsureInitialized(); } Here's my Web Api controller [RoutePrefix("api/admin/users/")

SendGrid Tutorial resulting in Bad Request

孤街浪徒 提交于 2019-12-08 17:07:00
问题 I apologize if this is a dupe question, but I have not found any solid information about this issue either on this site or on others. With that being said, I am working on an MVC 5 web application. I am following this tutorial over on ASP.net. public async Task SendAsync(IdentityMessage message) { await configSendGridasync(message); } private async Task configSendGridasync(IdentityMessage message) { var myMessage = new SendGridMessage(); myMessage.AddTo(message.Destination); myMessage.From =

unknown gap before input-group-addon in default asp.net mvc 5 template

时间秒杀一切 提交于 2019-12-08 16:18:21
问题 how to reproduce : create new ASP.Net MVC project add a model add a controller with scaffolding views open the Create.cshtml in browser , then change any "form-group" using firebug or developer tools : From : <div class="form-group"> <label class="control-label col-md-2" for="Name">Name</label> <div class="col-md-10"> <input name="Name" class="form-control text-box single-line" id="Name" type="text" value=""> </div> <span class="field-validation-valid text-danger" data-valmsg-replace="true"

How to set columns dynamically in Kendo template

谁说我不能喝 提交于 2019-12-08 16:14:55
问题 How to set columns dynamically in Kendo template for kendo grid.In my kendo grid,columns are subject to change dynamically based on user preference.How to dynamically create Kendo Template?I am using Kendo JavaScript,I can switch to Kendo MVC if same thing i can achieve there.Is there any other approach to achieve this? <script id="rowTemplate" type="text/x-kendo-template"> <tr class="k-master-row"> <td> <div>#=column1#</div> </td> <td><span class="mydesign" title="column2#"</span></td> <td>

MVC 5 - RedirectToAction Not Redirecting

余生长醉 提交于 2019-12-08 16:01:07
问题 Hi I have a problem with my RedirectToAction not redirecting. My code successfully hits a breakpoint placed on the Redirect so I can confirm it is being called. Nothing seems to happen however. I have tried looking at the network traffic in Chrome and there doesn't seem to be anything obvious. I must be missing something simple! // // POST: /Blog/CreateBlog [HttpPost] [ValidateAntiForgeryToken] public ActionResult CreateBlog(BlogViewModel model) { var userId = User.Identity.GetUserId(); model