asp.net-mvc

A simple ASP .NET MVC API controller using roles

老子叫甜甜 提交于 2021-02-07 11:13:59
问题 I wrote a web application using ASP .NET MVC and authorization system by default. I configured IdentityRole and input through external providers. Using the current database I have created my data context. Now I want to write a Xamarin.Android app and connect to my database, I want a simple API. But the feature that you want to access this API was only available to user with a certain role. The API is really very simple and therefore do not want to add to the draft WCF or WebAPI project. How

Modal Pop Up in mvc 5 [closed]

孤街醉人 提交于 2021-02-07 10:48:24
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Improve this question I want to open modal window when user click create new link. Mvc automatically generates create view in default but it open in another page. I want it to load in Bootstrap pop-up 回答1: Please Use below example. Button/Link, Here I am take button <button type="button" name="btnLink

MVC 5 Routing with parameter using @Url.RouteUrl

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-07 10:45:51
问题 I have an ActionResult that I have applied a routing attribute to: [Route("myproduct/{productID}", Name = "myproduct")] [MvcSiteMapNode(Title = "Products", ParentKey = "products", Key = "myproducts")] public ActionResult myproducts(int productID) ... I am trying to link to the view via a RouteUrl: <a href="@Url.RouteUrl("myproducts", @Model.myproducts[i].productID)">Buy</a> The resulting html does not even include a href: <a>Buy</a> If I remove the parameter it works: [Route("myproducts",

.NET Identity UserManager.FindAsyc throwing “Invalid column name 'Discriminator'.”

巧了我就是萌 提交于 2021-02-07 10:34:17
问题 I created a new .NET Web Application project and choose the Individual User Account Authentication for the template I selected. By default this sets up the Identity database to be a local database in the App_Data directory. This worked fine. But then I needed the AspNet tables for membership to be in my real SQL Server database that holds the rest of my application. So I changed the DefaultConnection string to point to my local SQL Server database and when I reran the application, EF

Convert a table with different relational values to excel columns

你离开我真会死。 提交于 2021-02-07 09:47:56
问题 I have these tables: Category CategoryId CategoryTitle ... ICollection<Article> Articles Each category can have several articles: Article ArticleId ArticleTitle NumberOfComment NumberOfView ... ICollection<ArticleReview> Reviews And each article has several reviews by some user: ArticleReview ArticleReviewId ReviewPoint ArticleId ReviewerId i am trying to export excel report using EPPlus package Here is my ExcelExport class : public class excelExport { public string ArticleTitle { get; set; }

Passing localstorage to controller using Ajax

只愿长相守 提交于 2021-02-07 09:24:25
问题 I need to access the data held in localstorage, server side but that's another story. I have this button in my view: <div style="float:right;"> <input id="btnTest" type="button" name="test Json Button" value="test Json Button" onclick="sendLocalStorage();" class="btn btn-default" /> </div> This JS function: function sendLocalStorage() { var JsonLocalStorageObj = JSON.stringify(localStorage); //var test = ["test1", "test2", "test3"]; $.ajax({ url: "/MyControllersName/Test", type: "POST",

Long running method in controller action - MVC [duplicate]

非 Y 不嫁゛ 提交于 2021-02-07 09:15:29
问题 This question already has answers here : Long running task in WebAPI (5 answers) Closed 6 years ago . I have a method similar to the following in WebAPI - MVC public IActionResult Post(Model model) { ALongRunningMethod(); return Ok(); } I have two options. Wait for the method to complete. But, what if its too long ? Doesn't the API timeout ? Run that in a separate thread using Tasks but return Ok (200 HTTP Code) immediately ? What if some exception occur in that long running method ? Totally

Build list of data validation attributes for a given element

北城余情 提交于 2021-02-07 09:12:51
问题 When using any of the Input Extension Helper Methods, like @Html.TextboxFor, any Validation Attributes from your model are automatically generated by the Razor engine (via ClientValidationEnabled/UnobtrusiveJavaScriptEnabled). For example, take the following case which works fine Model : [Required] public string QuestionOne { get; set; } View : @Html.TextBoxFor(model => model.QuestionOne) @Html.ValidationMessageFor(model => model.QuestionOne) Generated Markup : <input type="text" id=

Build list of data validation attributes for a given element

橙三吉。 提交于 2021-02-07 09:12:47
问题 When using any of the Input Extension Helper Methods, like @Html.TextboxFor, any Validation Attributes from your model are automatically generated by the Razor engine (via ClientValidationEnabled/UnobtrusiveJavaScriptEnabled). For example, take the following case which works fine Model : [Required] public string QuestionOne { get; set; } View : @Html.TextBoxFor(model => model.QuestionOne) @Html.ValidationMessageFor(model => model.QuestionOne) Generated Markup : <input type="text" id=

Having classic ASP read in a key from appsettings in a web.config file

别说谁变了你拦得住时间么 提交于 2021-02-07 08:46:14
问题 OK so here's the situation. I've got a classic ASP website running inside an MVC 4 application. I need the classic ASP website to be able to get a key from the appsettings section of the web.config file. Here is the function I've got: ' Imports a site string from an xml file (usually web.config) Function ImportMySite(webConfig, attrName, reformatMSN) Dim oXML, oNode, oChild, oAttr, dsn Set oXML=Server.CreateObject("Microsoft.XMLDOM") oXML.Async = "false" oXML.Load(Server.MapPath(webConfig))