asp.net-mvc-5

“The SMTP host was not specified.” - but it is specified?

一世执手 提交于 2019-12-03 23:44:56
I'm slightly baffled here - I'm receiving the following error: The SMTP host was not specified. Even though my code appears to be correct (from what I can see). I am able to do it manually by including all the details inside of the controller, e.g. SmtpClient smtpClient = new SmtpClient("smtp.gmail.com"); smtpClient.Port = 587; ... etc But I shouldn't have to do this, as I want to use the details inside mailSettings (Making it re-usable for various different controllers). mailSettings in my Web.Config file: <system.net> <mailSettings> <smtp from="example@gmail.com" deliveryMethod="Network" >

Is there a way I can debug a route in ASP. MVC5? [duplicate]

独自空忆成欢 提交于 2019-12-03 23:35:40
问题 This question already has answers here : How do you debug MVC 4 API routes? (5 answers) Closed last year . In the past I have used some code by I think Scott Hanselman of Microsoft. However now I am using MVC5 and I don't think that code is valid any more. Is there a way I can trace routes taken in MVC5 so that I can know why I see messages like: HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. 回答1: I know it

Direct download link to ASP.NET MVC 5 for VS 2012 [closed]

天大地大妈咪最大 提交于 2019-12-03 23:35:14
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'm looking for a direct link to ASP.NET MVC 5 install package for Visual Studio 2012, in downloads of asp.net i found only packages with Azure, but i need package without it. JasCav Per this Stackoverflow answer , and one of the responses to this Razor Intellisense bug , Microsoft does not plan on shipping tooling for VS2012 and MVC5 until November 2013. UPDATE Per IT Hit WebDav's comments, I wanted

Unable to add and fetch custom claims values

孤街醉人 提交于 2019-12-03 23:33:36
问题 I am using mvc 5 with identity 2.0. I want use custom claim values over the application but I get null value. What am I doing wrong? Updated code Login Code in account controller if (!string.IsNullOrEmpty(model.UserName) && !string.IsNullOrEmpty(model.Password)) { AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie); var result = SignInManager.PasswordSignIn(model.UserName, model.Password, model.RememberMe, shouldLockout: false); //Generate verification token Dictionary

How to create a security stamp value for asp.net identity (IUserSecurityStampStore)

流过昼夜 提交于 2019-12-03 23:25:08
In my MVC-5 application, I have to create security stamp values manually . The current implementation of the identity team seems to use a guid. Guid.NewGuid().ToString("D") Is it safe to create a new Guid myself to use as a new security stamp value or will this lead to problems in future implementations of asp.net identity? Is there a method to let the identity framework create such a stamp-value for me so that my implementation is safe for future changes? Out of the documentation of the identity implementation for the entity-framework, it seems that it can be any random value: IdentityUser

Mvc retain values after postback

天涯浪子 提交于 2019-12-03 22:15:12
I have a simple TestController class and User model: public class TestController : Controller { public ActionResult TestAction() { return View(); } [HttpPost] public ActionResult TestAction(User user) { return View(); } } public class User { public int Id { get; set; } public string Name { get; set; } public int Age { get; set; } } This is my form: As far as I know MVC is stateless and it does not have a viewstate concept. But after posting the data to my controller and when I return the view, all my data is there. I expect empty fields but they are all filled with the posted data. I could not

Asp.net identity Google account id migration from openId to oauth

▼魔方 西西 提交于 2019-12-03 21:05:40
I have an existing asp.net mvc5 application using DotNetOpenAuth for Google OpenId authentication. I am migrating to Asp.Net Identity, and using Google+ Auth with OAuth2.0. But I have seen thant I can't map existing OpenId account Id to OAuth2.0 Id : - Old id is : https://www.google.com/accounts/o8/id?id=blablabla - New Id is : a long number Since I would like to use new id, I am searching for help on migrating identities. I have not found yet a simple sample to achieve this. I am using a new asp.net mvc5 application (freshly scaffolded), added Microsoft Identity (with custom implementation

Specify different _Layout.cshtml depending on controller

眉间皱痕 提交于 2019-12-03 20:45:32
I created an asp mvc3 project, I want to have a different _Layout.cshtml depending on which controller is selected. This is because with controller 1 it has 2 buttons with the controller2 there will be 3 and with the controller3 there will be 4. Each controller is for a specific type of user, so it depends on the login. How can i link a controller and its views to another Layout.cshtml, right now there is one layout and it's under the Shared folder. Thanks! The View should determine the layout, not the controller. The Controller should just determine what View is returned. Then in the top of

How does redirect to returnUrl work in Asp.Net MVC5

若如初见. 提交于 2019-12-03 19:31:00
问题 I've started a new MVC 5 site, using the new Asp.Net Identity with Owin. In my "account" controller which has the attribute [Authorize], I have fairly standard actions; // GET: /User/Login [AllowAnonymous] public ActionResult Login(string returnUrl) { ViewBag.ReturnUrl = returnUrl; return View(); } // POST: /User/Login [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> Login(LoginViewModel model, string returnUrl) { try { if (ModelState.IsValid) { var

MVC 5, Identity 2.0 Android Rest/Json Api

人盡茶涼 提交于 2019-12-03 19:29:45
I have an ASP.NET MVC 5 Application which uses Identity 2.0 for authentication/authorisation. Now I want to provide access to the data in my web application to my Android Application via Web Api 2.0. My question is: How to control authorize/authenticate the access of my android application? On Android side I use "org.springframework.web.client.RestTemplate" and add this HTTP header to my request: HttpAuthentication authHeader = new HttpBasicAuthentication("username", "password"); HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.setAuthorization(authHeader); HttpEntity<?>