razor

Image display on MVC view

帅比萌擦擦* 提交于 2020-07-16 16:45:25
问题 I am trying to display image on the cshtml file. The spam filter prevents me from typing the HTML for image. However the source is set to src= "@Html.Encode(Model.PictureLocation)" alt="IMAGES" In viewsource it shows as src= "C:\Documents and Settings\xxx\My Documents\Visual Studio 2010\Projects\MVC\TIQC_ServerInterface\TIQC_ServerInterface\uploads\FileUpload12011_03_02_11_49_22.jpg" alt="IMAGES" The image is present in the location mentioned in the src path. On execution, the page is not

How do you avoid the EF Core 3.0 “Restricted client evaluation” error when trying to order data from a one-to-many join?

馋奶兔 提交于 2020-07-16 08:22:24
问题 I have a table I'm displaying in a site which is pulling data from a few different SQL tables. For reference, I'm following this guide to set up a sortable table. Simplify the model, say I have a main class called "Data" which looks like this (while the Quotes class stores the DataID): namespace MyProject.Models { public class Data { public int Id { get; set; } public string Name { get; set; } public int LocationId { get; set; } public Models.Location Location { get; set; } public IList

Setting a new landing page in ASP.NET Core MVC

六眼飞鱼酱① 提交于 2020-07-09 07:18:19
问题 I need to set a new landing page for my application. For now it is landing on the standard Index.cshtml inside of the Home folder inside of the Views folder. I want my new landing page to be from this directory: Views/Welcome/Index.cshtml The error I'm getting says: InvalidOperationException: RenderBody has not been called for the page at '/Views/Welcome/Index.cshtml'. To ignore call IgnoreBody(); I have made the following changes so far in my startup.cs file: public void ConfigureServices

Strange whitespace appearing in MVC4 Razor View

折月煮酒 提交于 2020-07-08 04:20:24
问题 I'm developing an app in ASP.Net MVC4 and am having a strange issue with whitespace. I've developed plenty of MVC3 sites with Razor without this issue. Here's my template cshtml file: <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>HF - Content Management - @ViewBag.Title</title> <link href="@Url.Content("~/content/bootstrap/bootstrap.min.css")" rel="stylesheet" /> @Styles.Render("~/bundles/css/hf-cms-logged-in") </head> <body> @Html.Partial(

Strange whitespace appearing in MVC4 Razor View

别等时光非礼了梦想. 提交于 2020-07-08 04:20:10
问题 I'm developing an app in ASP.Net MVC4 and am having a strange issue with whitespace. I've developed plenty of MVC3 sites with Razor without this issue. Here's my template cshtml file: <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>HF - Content Management - @ViewBag.Title</title> <link href="@Url.Content("~/content/bootstrap/bootstrap.min.css")" rel="stylesheet" /> @Styles.Render("~/bundles/css/hf-cms-logged-in") </head> <body> @Html.Partial(

ASP.NET Core Razor - AJAX Post - 400 Bad Request

[亡魂溺海] 提交于 2020-07-08 04:05:50
问题 AJAX POST in ASP.NET Core Razor page will not work. It always returns a 400 Bad Request. I have the following page method code : [ValidateAntiForgeryToken] public async Task<IActionResult> OnPostProcessCCPaymentAsync(CheckInPaymentModel checkInPaymentModel) { return new JsonResult(checkInPaymentModel.AmountExtra); } The following is set in the page : @Html.AntiForgeryToken() And the following JS AJAX call : $.ajax({ type: "POST", url: "/CheckIn/Payment?handler=ProcessCCPayment", contentType:

Howto debug JavaScript inside ASP .Net Core 3.1 MVC applications (Razor view - *.cshtml)?

☆樱花仙子☆ 提交于 2020-07-07 19:55:24
问题 I have latest Visual Studio 2019 16.5.4 Enterprise . I've just created an ASP .Net Core 3.1 MVC application from a template (with default settings). And I've added some JavaScript code to a Home Page's Index.cshtml : @{ ViewData["Title"] = "Home Page"; } <div class="text-center"> <h1 class="display-4">Welcome</h1> <p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p> </div> @section Scripts { <script> function GetJSON_Simple() { var resp

CSS from Blazor Component Lib not loaded

江枫思渺然 提交于 2020-07-06 19:59:57
问题 I want to use my customs CSS located on the wwwroot/css/. in my BlazorControllers/Components/. files but nothing is loaded at execution. Is there something to specify in the client or in the lib project settings ? My Library project is BlazorControllers and I use the component of the library in the Client project 回答1: In your Index.html (or _Host.cshtml) file, below the site.css line, add <link href="_content/<YourLibrary>/styles.css" rel="stylesheet" /> where <YourLibrary> seems to be

ASP.NET MVC locating cs files generated from cshtml?

风流意气都作罢 提交于 2020-07-05 02:46:08
问题 So I've recently started with ASP.NET MVC 4. I'm using the razor engine. My question is concerning the view files, with suffix cshtml. It seems to me that these are precompiled into *.cs files by razor which in turn are then compiled into MSIL. (A pattern that is familiar from my days as a JSP developer.) One reason why I am making this assumption is that if I enter some invalid c# code into the cshtml file I get a compilation error displayed like this: Line 34: public class _Page_Views

ASP.NET MVC locating cs files generated from cshtml?

牧云@^-^@ 提交于 2020-07-05 02:45:02
问题 So I've recently started with ASP.NET MVC 4. I'm using the razor engine. My question is concerning the view files, with suffix cshtml. It seems to me that these are precompiled into *.cs files by razor which in turn are then compiled into MSIL. (A pattern that is familiar from my days as a JSP developer.) One reason why I am making this assumption is that if I enter some invalid c# code into the cshtml file I get a compilation error displayed like this: Line 34: public class _Page_Views