asp.net-mvc-5

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

扶醉桌前 提交于 2019-12-02 18:35:26
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 to do is to add table Post into existing Default Database, created by MVC 5 project. I've made model

ASP.NET Web API generate url using Url.Action

[亡魂溺海] 提交于 2019-12-02 17:55:18
How can I generate the same url but in Web Api ? var url = Url.Action("Action", "Controller", new { product = product.Id, price = price }, protocol: Request.Url.Scheme); P.S. The url should be generated to an MVC controller/action but from within web api. So basically: make a get request to my api/generateurl and that will return an url to : http://domain.com/controller/action?product=productId&price=100 Viktor Bahtev Maybe the closest helper to Url.Action in Web Api Controller is the Url.Link method which will generate the url by Route name, Controller Name, Action Name and the route

How does @Html.BeginForm() work? and search result in Microsoft ASP.Net MVC 5 tutorial?

喜夏-厌秋 提交于 2019-12-02 17:53:54
I am working on MVC 5 Asp.Net and following this tutorial. I am wondering how the heck does this fetch the result when I click the Filter button? There comes a point where this code is added in Movie/view/Index.cshtml @using (Html.BeginForm()) { <p> Title: @Html.TextBox("SearchString") <br /> <input type="submit" value="Filter" /></p> } Now as far as I know, it creates a textbox and a button on screen. But how is this button calling the search(index) function and passing the value of textbox in the function, I could not get this. Dejan.S It's not a stupid question. @html.BeginForm() works like

MVC 5 - can not get globalisation running

人盡茶涼 提交于 2019-12-02 17:52:29
问题 I want to add globalization because the site asks the user for a date. And my german user want to type "31.12.1966" and not "1966-12-31". So I add the nuget-Packages "jQuery.Validation.Globalize" and "jquery-globalize" to the project. Now I am not able to configure my BundleConfig! From my research I know, that I Need globalize.js and some other files. So I try to make a bündle: bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js")); bundles.Add(new

How do I properly register AutoFac in a basic MVC5.1 website?

▼魔方 西西 提交于 2019-12-02 17:41:01
AutoFac has recently been updated for MVC 5.1 but at the time of writing I find that the documentation is lacking (especially for a simple example). I would like to inject dependencies into MVC Controllers and register my own implementations for e.g. e-mail (actual sending vs print to output window) as a basic example. I'm do not know if I am missing a good resource for this and I am slight concerned that because it uses the OWIN specification that the implementation may differ for MVC5.1 (ASP.NET Identity uses OWIN and there is some special attributes used to properly instantiate OWIN) so

MVC 5 Identity Automatic Logout

自闭症网瘾萝莉.ら 提交于 2019-12-02 17:32:11
How do I implement an Automatic Logout Timer. So basically if the user is inactive for x minutes their session is ended? I have tried: <system.web> <sessionState timeout="1"/> </system.web> But it doesn't seem to work. Here is code that is in my startup: public void ConfigureAuth(IAppBuilder app) { // Enable the application to use a cookie to store information for the signed in user app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login") }); } Which says that I am using cookie

Visual Studio 2013 Scaffolding Error

自古美人都是妖i 提交于 2019-12-02 17:30:41
I'm using VS 2013 RTM Ultimate, and when I try to add a Controller to my MVC 5 project I get the following error: "There was an error running the selected code generator: 'The Parameter searchFolders does not contain any entries. Provide at least one folder to search files.' None of the scaffolders work basically, all giving the same error... Tried rebuidling / clean etc and still get error. Update Oct 28: Looks like it is a problem with having T4Scaffolding installed. Looks like they are working on a fix. AKhooli If you have recently installed a package with T4Scaffolding dependency (ex.

How to create dependency injection for ASP.NET MVC 5?

久未见 提交于 2019-12-02 17:17:22
Creating Dependency Injection with ASP.NET Core is fairly easy. The documentation explains it very well here and this guy has a killer video to explain it. However, I want to do the same thing with my ASP.NET MVC 5 project. How can handle dependency injection with ASP.MVC 5? Also, is Dependency injection limited to controllers only or can it work with any class? In ASP.Net MVC you can use the .Net Core DI from NuGet rather than one of the third-party alternatives:- using Microsoft.Extensions.DependencyInjection For the MVC Start/Configuration class:- public void Configuration(IAppBuilder app)

Is it possible to post on facebook wall an edited google map?

我的未来我决定 提交于 2019-12-02 17:14:38
问题 My ASP.Net MVC5 application allows users to create their own trip database using google maps api. Now I would like to allow them to post on their facebook walls those trips. Do you have any ideas on how I can achieve this? I don't need a final answer, I would be more than satisfied with some insight about it. 回答1: I guess you could use OpenGraph Custom Stories to achieve that. Have a look at the guide at https://developers.facebook.com/docs/opengraph/getting-started to get an overview.

Post an HTML Table to ADO.NET DataTable

北城以北 提交于 2019-12-02 17:06:26
问题 I have a HTML table as below in my View: <table id="tblCurrentYear"> <tr> <td>Leave Type</td> <td>Leave Taken</td> <td>Leave Balance</td> <td>Leave Total</td> </tr> @foreach (var item in Model.LeaveDetailsList) { <tr> <td>@Html.TextBoxFor(m => item.LeaveType, new { width = "100" })</td> <td>@Html.TextBoxFor(m => item.LeaveTaken, new { width = "100" })</td> <td>@Html.TextBoxFor(m => item.LeaveBalance, new { width = "100" })</td> <td>@Html.TextBoxFor(m => item.LeaveTotal, new { width = "100" })