razor

how to change modelview via Ajax with dropdownchange value?

亡梦爱人 提交于 2020-06-28 03:55:19
问题 im stuck with a code. on my mvc application, i had a view, the view contains a dropdownlist, and a bar chart from charts.js nugget. the datasources of the chart are the model.field1, and model.field2 for each axis, so, im trying, to, when i change dropdownlist item my model change , im passing the dropdownlist.val() to an action in the controller, that action change the model, the model returns chaged to the view and the chart must change dinamicly, i post my code, dont know what i doing

Anchors with asp-controller and asp-action attribute don't get rendered as links

≡放荡痞女 提交于 2020-06-27 13:17:15
问题 In this Razor syntax: <a asp-controller="Home" asp-action="Index">Home</a> @foreach (LinkNodeModel link in Model.ControlActions) { link.LinkTree(); } The "Home" link renders just fine, but the manually rendered <a> strings don't get turned into a valid link. LinkTree() is implemented like this: return $"<a asp-controller=\"{Controller}\" asp-action=\"{Action}\">{Name}</a>"; When I print the links with the @link.LinkTree() , the output contains a line with just the code displayed, which doesn

Multi Tenant Razor pages

与世无争的帅哥 提交于 2020-06-27 09:03:12
问题 I am trying to set up Razor Pages routing to allow different views to be rendered for different tenants. I have a directory structure as follows: /Pages Test.cshtml.cs /Tenant1 Test.cshtml /Tenant2 Test.cshtml Given I am already able to decide which tenant is required, how is it possible to configure the routing to map some path eg localhost:8080/Test to either Tenant1/Test or Tenant2/Test views. 回答1: Use dynamic view content (via partial views). With this solution, the Test page will

How to change root path ~/ in Razor in asp.net core

£可爱£侵袭症+ 提交于 2020-06-25 08:54:08
问题 The simplest question for which I can't find an answer. I have an asp.net core 2.1 MVC application with Razor. Application widely uses ~/path syntax. Everything works great if application runs from domain root (for example, from http://localhost:5000/) But when I run application at non-root (for example, http://localhost:5000/app) the Razor still uses root ( / ) as base path. Question: how to configure this? How to specify base path for Razor's ~/ ? There must be an environment variable for

How to change root path ~/ in Razor in asp.net core

故事扮演 提交于 2020-06-25 08:53:22
问题 The simplest question for which I can't find an answer. I have an asp.net core 2.1 MVC application with Razor. Application widely uses ~/path syntax. Everything works great if application runs from domain root (for example, from http://localhost:5000/) But when I run application at non-root (for example, http://localhost:5000/app) the Razor still uses root ( / ) as base path. Question: how to configure this? How to specify base path for Razor's ~/ ? There must be an environment variable for

How to change root path ~/ in Razor in asp.net core

空扰寡人 提交于 2020-06-25 08:53:15
问题 The simplest question for which I can't find an answer. I have an asp.net core 2.1 MVC application with Razor. Application widely uses ~/path syntax. Everything works great if application runs from domain root (for example, from http://localhost:5000/) But when I run application at non-root (for example, http://localhost:5000/app) the Razor still uses root ( / ) as base path. Question: how to configure this? How to specify base path for Razor's ~/ ? There must be an environment variable for

How to add css/script only to a Partial view?

大憨熊 提交于 2020-06-22 12:40:28
问题 I need to load css and scripts only to a specific Partial view but at this moment this link and scripts are loaded in all views. The structure that I have is the main view embedded a _Layout and Header, and the Header embedded a partial view called SearchHeader. _Layout -> View <- Header <- SearchHeader Header: <li id="_Header_Menu"> <div> <ul class="sf-menu"> <li> @Html.Partial("../Home/SearchHeader") </li> </ul> </div> </li> SearchHeader: <html> <head> <link href="@Url.Content("~/Content

What ../path and ~/path Indicates in MVC?

六月ゝ 毕业季﹏ 提交于 2020-06-12 06:29:08
问题 I have one custom helper class called Image which is having two arguments: src alt Now I am going to call that in one of View, @Html.Image("../Images/Indian.gif","Image is not supported or exist") <img src="~/Images/Indian.gif" alt="Image is not supported or exist" /> Now, this both will give me same result but I am confused that why the path was not the same for both and what "../path" and "~/path" indicate? This two-line it generates when I do inspect element in a web browser: <img alt=

400 Bad Request when POST-ing to Razor Page

倾然丶 夕夏残阳落幕 提交于 2020-06-10 02:59:27
问题 My page has... @page "{candidateId:int}" ... and @Html.AntiForgeryToken() Model has... public void OnGet(int candidateId) { } public void OnPost(int candidateId) { } GET works fine. Here is my AJAX request.. $.ajax({ type: "POST", url: "/Skills/" + candidateId, beforeSend: function (xhr) { xhr.setRequestHeader("XSRF-TOKEN", $('input:hidden[name="__RequestVerificationToken"]').val()); }, data: { name: 'hi mum' }, success: function (response) { }, failure: function (response) { alert(response);

400 Bad Request when POST-ing to Razor Page

落花浮王杯 提交于 2020-06-10 02:59:04
问题 My page has... @page "{candidateId:int}" ... and @Html.AntiForgeryToken() Model has... public void OnGet(int candidateId) { } public void OnPost(int candidateId) { } GET works fine. Here is my AJAX request.. $.ajax({ type: "POST", url: "/Skills/" + candidateId, beforeSend: function (xhr) { xhr.setRequestHeader("XSRF-TOKEN", $('input:hidden[name="__RequestVerificationToken"]').val()); }, data: { name: 'hi mum' }, success: function (response) { }, failure: function (response) { alert(response);