asp.net-mvc-5

Web.tt in VS 2013 MVC project causes error “value does not fall within the expected range”

狂风中的少年 提交于 2019-12-23 14:24:17
问题 Has anyone else encountered this in VS 2013? Any way of fixing? Create a new asp.net web application with visual studio 2013. Under "Add folders and core references for:", check MVC. Click OK. Open the web.config and copy the contents. Add a new text template to your project called "Web.tt" Paste in the contents of your web.config and change the output extension to be .config. all you need is this line (and then your web.config contents after it): <#@ output extension=".config" #> Make sure

How to use the same route with different parameter types?

和自甴很熟 提交于 2019-12-23 12:49:28
问题 I have an Api controller with two different actions that take different parameter types. // GET: users/sample%40email.com [Route("users/{emailAddress}")] public IHttpActionResult GetUser(string emailAddress) // GET: users/1D8F6B90-9BD9-4CDD-BABB-372242AD9960 [Route("users/{reference}")] public IHttpActionResult GetUserByReference(Guid reference) Problem is multiple actions are found matching when I make a request to either. Looking at other answers I thought I needed to setup routes in the

ASP MVC 5 Attribute routing not registering routes

核能气质少年 提交于 2019-12-23 12:31:04
问题 Overview I'm currently trying to get attribute routing to work with my api controllers. It doesn't appear to be working, and I'm unsure why. I'm not sure if I'm missing a crucial step, or what the problem could be. Problem I'm trying to hit localhost/api/user/custom?test=1 but I get a 404 (I expect this to work) If I hit localhost/api/customapi?test=1 I successfully get into my method Why does the first url not work? Setup My setup is as follows: CustomController.cs [System.Web.Mvc

HTML5 change datetime format

别来无恙 提交于 2019-12-23 12:26:06
问题 I am displaying the datetime values in a readonly textbox(type="text") and it is rendered correctly. But when I try to save it, HTML5 highlights the textbox border which I think means that it has failed HTML5 date validation. Is it because of the format? If it is then how to change the format?. The other option, if possible, could be to disable the default html5 validation but I am curious to know its behaviour. The server side code is below: <div class="panel-body in"> <fieldset class=

How to pass tempdata in RedirectToAction in ASP.Net MVC

可紊 提交于 2019-12-23 12:16:04
问题 I need to pass one logout successful message in one of the views but I am not able to do so. Here is what I have. Not Working Solution: //LogController: public ActionResult Logoff() { DoLogOff(); TempData["Message"] = "Success"; return RedirectToAction("Index", "Home"); } // HomeController public ActionResult Index() { return View(); } Index CSHTML File: @Html.Partial("../Home/DisplayPreview") DisplayPreview CSHTML File: @TempData["Message"] Working Solution public ActionResult Logoff() {

Elmah showing, “No OWIN authentication manager is associated with the request.”

怎甘沉沦 提交于 2019-12-23 12:14:41
问题 My elmah logs is showing this error. This is not happening with every requests. It happening intermittently. MVC 5.2, Web API 2.2, ASP.NET Identity 2 and Azure website is my environment. update: Here is my Startup.cs, OAuthOptions = new OAuthAuthorizationServerOptions() { AllowInsecureHttp = true, TokenEndpointPath = new PathString("/token"), AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(settings.AccessTokenExpireTimeSpanInMinutes), Provider = new MyAuthorizationServerProvider(),

Version Deprecation Facebook Graph API v2.2

删除回忆录丶 提交于 2019-12-23 10:52:51
问题 our Facebook Login is not working right now. We have received a message from Facebook Developer Portal: "Name of app" currently has access to Graph API v2.2 which will reach the end of its 2-year lifetime on 27 March, 2017. To ensure a smooth transition, please migrate all calls to Graph API v2.3 or higher. To check if your app will be affected by this upgrade you can use the Version Upgrade Tool. This will show you which calls, if any, are affected by this change as well as any replacement

ASP.NET Identity Confirmation Email Is Plain Text Instead of HTML

不羁岁月 提交于 2019-12-23 10:49:33
问题 In an ASP.NET MVC5 C# application I am using the standard code for sending confirmation emails when a user registers, something I've done in multiple projects: var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); Normally when the recipient receives the email, it's content

Shouldn't OwinStartupAttribute run before global.asax and Application_Start?

落爺英雄遲暮 提交于 2019-12-23 10:28:22
问题 I need to run code before application start and up until now I have used WebActivator to do that but if I understand correctly the OwinStartupAttribute is more suitable for that but the problem for me is that it runs after Application_Start in Global.asax , is this correct or can I configure it to run pre application start? 回答1: According to this answer it runs slightly after Application_Start. So if you, just like me need to run code before Application_Start, WebActivator is still the way to

Shouldn't OwinStartupAttribute run before global.asax and Application_Start?

不问归期 提交于 2019-12-23 10:27:09
问题 I need to run code before application start and up until now I have used WebActivator to do that but if I understand correctly the OwinStartupAttribute is more suitable for that but the problem for me is that it runs after Application_Start in Global.asax , is this correct or can I configure it to run pre application start? 回答1: According to this answer it runs slightly after Application_Start. So if you, just like me need to run code before Application_Start, WebActivator is still the way to