razor-pages

How to open the starting file of an ASP.NET Core Razor Pages app?

人走茶凉 提交于 2020-03-04 18:44:31
问题 I have a basic question so apologies in advanced but I have been googling for hours and not been able to find the answer. I made an ASP.NET Core Razor Pages app and deployed it to a folder (which is in a network, it's basically our staging environment) and now need to know how to access the index page in the URL. I followed this doc on how to publish the app into a folder: https://docs.microsoft.com/en-us/dotnet/core/deploying/deploy-with-vs?tabs=vs156 (I chose the Self-contained deployment

Problem running project after Identity scaffolding in ASP.NET Core MVC project on Linux

穿精又带淫゛_ 提交于 2020-02-28 07:50:25
问题 I've tried adding <PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="2.2.0" /> However 2.2.0 is the latest version available at this time, which doesn't match the error. The error is still the same after rebuilding the app. project.csproj: <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> <RuntimeIdentifier>linux-x64</RuntimeIdentifier> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore

Problem running project after Identity scaffolding in ASP.NET Core MVC project on Linux

蓝咒 提交于 2020-02-28 07:48:30
问题 I've tried adding <PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="2.2.0" /> However 2.2.0 is the latest version available at this time, which doesn't match the error. The error is still the same after rebuilding the app. project.csproj: <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> <RuntimeIdentifier>linux-x64</RuntimeIdentifier> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore

ASP .NET Core Inject Service in custom page filter

时光毁灭记忆、已成空白 提交于 2020-02-01 05:24:24
问题 I have set a filter to work upon a specific folder and all pages inside it. I need to access database using a claim. The problem is that I cannot seem to register my filter with DI on startup services cause it does not find the database connection services.AddMvc() .AddRazorPagesOptions(options => { options.AllowAreas = true; options.Conventions.AuthorizeAreaFolder("Administration", "/Account"); options.Conventions.AuthorizeAreaFolder("Production", "/Account"); options.Conventions

Update label on post using Razor Pages

时间秒杀一切 提交于 2020-01-25 03:05:50
问题 I'm trying to update a label on an http post within a Razor Page. I have a public property called Confirmation as follows: public string Confirmation { get; set; } Then I have my post method: public async Task<IActionResult> OnPostAsync() { //some conditional logic here Confirmation = "Settings saved!"; return Page(); } In my view I have: <label asp-for="Confirmation"></label> However, this renders as: <label for="Confirmation">Confirmation</label> I don't want the word "Confirmation" showing

What am I missing that causes [TempData] decorated property not to retain value from get to post?

半世苍凉 提交于 2020-01-25 00:23:12
问题 My understanding of the TempData attribute in asp.net core is that it marks a model property as needing to persist in value between posts and gets of same page (and possibly wider lifetime than that, but at least that). My issue is that any property I have marked as TempData and set successfully in OnGetAsync has been reset to null by the time user posts back the form. Why might that be? Or have I misunderstood what TempData is supposed to do as an attribute? If I have, what's the best way to

How do I display a concatenated list from a model in another model's page model?

人盡茶涼 提交于 2020-01-24 00:50:08
问题 In my main index page, I would like to display a list of Officers in the Officer's Name column. i.e. Tommy Bahamas, Clinton K, etc... I am having difficulty because the Officer and SecurityLogOfficer table are not a part of my SecurityLog model on the index page. SecurityLog Index Page @foreach (var item in Model.SecurityLog) { <tr> <td style="width:4% !important"> @Html.DisplayFor(modelItem => item.ID) </td> <td style="width:5% !important"> @Html.DisplayFor(modelItem => item.EventDate) </td>

This version of Microsoft.AspNetCore.All is only compatible with the netcoreapp2.1 target framework

随声附和 提交于 2020-01-22 10:35:10
问题 When I try to publish my application to the web server after upgrading to .NET Core 2.1 from 2.0, I get this message: "This version of Microsoft.AspNetCore.All is only compatible with the netcoreapp2.1 target framework. Please target netcoreapp2.1 or choose a version of Microsoft.AspNetCore.All compatible with netcoreapp2.0." It runs fine on my development machine. Here is my project file: <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp2.1</TargetFramework>

Can Razor Class Library pack static files (js, css etc) too?

我的梦境 提交于 2020-01-19 04:50:48
问题 Maybe duplicate of this already, but since that post does not have any answer, I am posting this question. The new Razor Class Library is awesome, but it cannot pack libraries files (like jQuery, shared CSS). Can I somehow reuse the CSS across multiple Razor Page projects, either using Razor Class Library or anything else (my purpose is that, multiple websites use the same CSS, and a single change applies to all projects). I have tried creating the folder wwwroot in the Razor Class Library

XHR POST: to API Controller works, to Razor Page fails

拥有回忆 提交于 2020-01-16 09:01:27
问题 I have a standard ASP.NET Core Web application created from the Visual Studio template. I have a razor page which issues an XHR POST request with a payload upon a change event. If I make the url of the request an api controller in the application (i.e. under Controllers folder), the request succeeds. If I make the same request, same payload to a razor page method (under Pages folder), it fails with http 400. Both methods have the same signature. Can anyone describe why the behaviour is