asp.net-mvc-5

Why Asp.Net MVC 5 put @Scripts.Render(“~/bundles/jquery”) at the bottom in _Layout.cshtml?

青春壹個敷衍的年華 提交于 2019-12-03 06:53:52
问题 I put <script> blocks which use jQuery in the body of one (and only one) cshtml file which uses the template and they causes error because jQuery is not loaded yet. What's the point to put the @Scripts.Render("~/bundles/jquery") at the bottom of _Layout.cshtml file? The bottom of the _Layout.cshtml . @RenderBody() <hr /> <footer> </footer> </div> @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/bootstrap") @RenderSection("scripts", required: false) </body> </html> The following

MVC 5 OWIN login with claims and AntiforgeryToken. Do I miss a ClaimsIdentity provider?

拟墨画扇 提交于 2019-12-03 06:51:16
问题 I'm trying to learn Claims for MVC 5 OWIN login. I try'ed to keep it as simple as possible. I started with the MVC template and inserted my claims code (see below). I get an error when I use the @Html.AntiForgeryToken() helper in the View. Error: A claim of type 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier' or 'http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovid er' was not present on the provided ClaimsIdentity. To enable anti-forgery

Visual Studio 2015 - Shared Projects Reference Tab Missing on Web Project

两盒软妹~` 提交于 2019-12-03 06:49:55
问题 I upgraded to Visual Studio 2015 from our MSDN subscription because I was pretty excited to read about Shared Projects... No more managing 21382 nuget packages in our dependencies when all we want to do is reuse code. So I built a test shared project with some code in it. Then I add a new empty web application on .Net 4.6 to the project. Now I expected to go to references and see a "Shared Projects" tab on the references window, but I do not see one. Now I can add a class library to the same

infinite loop going back to authentication page when using OAuth in MVC5

谁说胖子不能爱 提交于 2019-12-03 06:49:45
I have written a webpage that takes advantage of Google/Facebook auth using MVC5 and OAuth sometimes, I'm able to auth very well using either Facebook or Google. It works quite well. However often what happens is Navigate to the login page Choose either google or facebook provide the account info, getting the necessary redirects redirect back to login page, but not logged in I'm not receiving (or not looking in the right place) any errors that clue me in - I am using SSL on Azure for hosting Does anyone have tips for why it sometimes works, and sometimes does not? this feels like it could be a

ASP.NET Identity 2 Remember Me - User Is Being Logged Out

隐身守侯 提交于 2019-12-03 06:23:20
I am using Identity 2.1 in my MVC5 app. I am setting the isPersistent property of the PasswordSignInAsync to true to enable 'Remember Me': var result = await SignInManager.PasswordSignInAsync(model.Username, model.Password, true, shouldLockout: false); But if I stay logged in overnight, then when I refresh the page in the morning, it logs me out and I have to sign in again. How do I prevent automatic logging out until the user manually logs out? Is it something to do with the Cookie Authentication that identity uses? I don't really understand the CookieAuthenticationOptions that are set in

Add new table to an existing database using Code First approach in EF 6 and MVC 5

感情迁移 提交于 2019-12-03 06:01:34
问题 I know this should be simple, but I was unable to find correct tutorial or explanation on web on this subject. There is a lot of videos and posts about adding new column to an existing table, using code first approach, but I can not find any with step by step explanation on how to add whole new table into existing database. Which is weird, I was pretty sure that I will find many examples. Maybe my search criteria is bad. So if anybody has any good link or video, please share. What I'm trying

POCO's with the new ASP.NET Identity and MVC 5.0 + claims-based Identity

倖福魔咒の 提交于 2019-12-03 05:58:46
With the new version of VS 2013 RTM and asp.net mvc 5.0, I’ve decided to try out a few things... Needless to say, a lot has changed. For example, the new ASP.NET Identity is a replacement of the old Membership and (less old) SimpleMembership APIs. In all previous applications I’ve built, I never had the chance to work with Membership or with SimpleMembership. I’ve always ended up creating my own Login() method which would convert a submitted ViewModel to a POCO (using automapper) which in turn, would use some sort of repository to lookup the user and password. In return, I would obtain a User

TextAreaFor Cannot Set Width

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 05:52:24
I cannot set the width or cols in atextarea. Rows/Height works just fine. can someone please help thanks! @using (Html.BeginForm()) { @Html.AntiForgeryToken() @Html.ValidationSummary(true) @Html.TextAreaFor(model => model.Comments, new {cols=60, rows=10}) @Html.HiddenFor(model => model.UserName, new { UserName = @User.Identity }) <div class="form-group"> <div class="col-md-10"> <input type="submit" value="Submit Feedback" class="btn btn-default" /> </div> </div> } Any advice or tips would be greatly appricated! thanks The HTML rendered is (I removed name and value text for security reasons:

“Generic” OpenID in ASP.NET MVC 5

社会主义新天地 提交于 2019-12-03 05:43:29
I played around with the new authentication features in ASP.NET MVC 5 (I previously used DotNetOpenAuth ). I understand that the built-in Google provider uses OpenID [1] (and it works fine), but I want to use my own OpenID provider when authenticating. Unfortunately, I was not able to find an easy way to accomplish this with the out-of-the-box features of ASP.NET MVC 5. I looked through the source of Microsoft.Owin.Security.Google and based on this it seems quite possible to add a new OpenID provider. Is there an easier (maybe already built-in) way to add a new OpenID provider to an ASP.NET

Hiding links from certain roles in ASP.NET MVC5

烈酒焚心 提交于 2019-12-03 05:40:45
So this may sound a dumb question, but how do I show a link only for an admin user? Suppose an ordinary user sees the following links: Home / About / Contact And an admin user sees the following links: Home / About / Contact / Admin I tried restricting in the controller and linking the controller on the menu. But it still shows the link for everyone, just doesn't allow access to anyone but admin Can the views be overloaded? Depending on what sort of Membership/User provider you are using, you should just be able to check directly from the View if the user is logged in and in the specific role.