Questions tagged [razor-pages]

1

votes
2

answer
654

Views

ASP.NET Core ViewData, BindProperty or TempData?

In ASP.NET Core Views and Razor Pages we can use: public class LoginModel { [BindProperty] public bool DisplayCaptcha { get; set; } // OR [ViewData] public bool DisplayCaptcha { get; set; } // OR [TempData] public bool DisplayCaptcha { get; set; } } To share data between View/Page/Controller... But...
Vanderlei Pires
1

votes
2

answer
336

Views

asp-for in checkbox throws and error in asp.net core

Here i have used two checkbox Send Report Send Invoice and data type for both checboc i.e asp-for='SendReport' and asp-for='SendInvoice' is bit. Now the problem is that when ever i try to load the page its throws error as below Unexpected 'asp-for' expression result type 'System.Nullable`1[[System.B...
redcaper71
1

votes
1

answer
433

Views

ASP.Net Core 2 - How can I get Visual Studio Code to detect Razor Pages?

In Asp.net core 2, they introduced razor pages. Using visual studio code if I create a 'Pages' folder in the root of the solution and then add a new item 'Greeting.cshtml', then add an @page directive at the top followed by the content I want to display, I don't see anything when I navigate to http:...
User123
1

votes
1

answer
1.3k

Views

Bootstrap Multiselect in ASP.Net Core Razor Page does not show the drop-down when clicked

I am unable to get the bootstrap multiselect drop-down to work in my View. I simply get the button pictured here . However, clicking on it does not trigger the drop-down to appear. Below is my code snippet and the css/js files I'm including. I did not catch any errors in the browser dev tools. Am I...
user1860688
1

votes
0

answer
66

Views

What are the drawbacks of implementing Web Api using inline handler methods of razor pages

As Razor pages can have inline handler methods and pages can be added to a running website without a full deployment. @page @{ public void OnGet() { } public void OnPost() { } } Thinking of a case when this dynamic addition to site features is a real plus point. What are some drawbacks (apart from...
eadam
1

votes
0

answer
652

Views

Running an ASP.NET Core Pipeline using Azure Functions

This was posted back in August https://social.msdn.microsoft.com/Forums/expression/en-US/c3e9f882-541f-48a2-a856-956ad3383f67/running-an-aspnet-core-pipeline-using-azure-functions He talks about using a catch-all function and then somehow running the HttpRequestMessage through Asp.Net Core How can I...
Paul Shell
1

votes
0

answer
85

Views

asp-page tag helper inserts encoded url inside form

I have a razor page with two page handlers: public IActionResult OnGetDisTest(int Id) { discussion = _service.GetDiscussion(Id, null); return Page(); } public IActionResult OnGetDisTestThread( int Id) { discussion = _service.GetDiscussion(null, Id); return Page(); } Accessing...
greedyLump
1

votes
1

answer
63

Views

Return dropdown string from second table

I have two tables I need to join for my Razor Page view. The first table called 'Account' contains an Account record with a int Status. The second table called 'AccountStatuses' contains possible statuses for the Account. Scaffolding created the following code in Account\Index.cshtml.cs public IL...
MikeK
1

votes
3

answer
1.9k

Views

How to create a button that will go to a razor page when clicked (“Razor page” in dotnet core 2)

I can use an anchor tag helper to go to a different razor page (from an existing razor page) e.g. this works: How can I get a similar thing to work but using a button. I have tried: EditReport But the page never loads. I also tried using the page handler with different variations of: and associated...
Blingers
1

votes
1

answer
306

Views

OAuth2 webapp implementing GitHub webhooks, in .Net CORE

I am trying to build an OAuth2 web application that implements GitHub webhooks. This seems only to be possible using AspNetCore 2.1. To implement webhooks in my project I first have to reconfigure services.AddMvc() in the startup.cs to services.AddMvcCore().AddGitHubWebHooks() This generates errors...
Johan Söderlund
1

votes
0

answer
151

Views

Custom RazorPages RazorViewEngine for .vbhtml file extensions

There is a Github issue that shares my frustration with the lack of support for Visual Basic in ASP.Net Core Web Applications and RazorPages. The following quotes from other GitHub issues add to this frustration: The .vbhtml razor engine from MVC 5 wasn't ported to Core primarily because less than...
tb-mtg
1

votes
0

answer
655

Views

Combine asp-route-id with asp-route-all-data

Is there any way to make this work? Action This generates the following link: sitename.com/controller/action?parm1=parm1&parm2=parm2 etc. I want it to generate this: sitename.com/controller/action/{id}?parm1=parm1&parm2=parm2 It seems as though you cannot combine the route-id with asp-route-all-dat...
dave317
1

votes
2

answer
705

Views

Razor Pages - Issue with Partial View and Getting Data from Model

I'm currently learning ASP.net Core 2.0, specifically Razor pages. I'm currently trying to understand partial views. I have a page, ViewReport, which essentially shows the data for a report and allows the user to edit it. The model looks like this: namespace ReportControlPanel.Pages { public class...
Molenpad
1

votes
1

answer
234

Views

Updating one-to-many relationships with Razor Pages

I cannot figure out how to update related data using Razor Pages asp.net core 2.0. In the below example, I can update the 'Project' data, but I cannot see the related 'Action' data (one project => many actions) on OnPostAsync(). EditModel : PageModel [BindProperty] public Project Project { get; se...
user797833
1

votes
0

answer
144

Views

Increase 2 min timeout on ASP.NET Core 2.0 web app hosted in Azure

I get the following error message with this code after exactly 2 minutes: 'The specified CGI application encountered an error and the server terminated the process'. public async Task AddRange(IList items) where TEntity : class { _db.AddRange(items); return await _db.SaveChangesAsync() >= 0;; } I'm...
MatSer
1

votes
2

answer
3.2k

Views

.NET Core - 404 error on server only

I have a very simple .NET Core test application that runs on my development machine but causes a 404 when run on my server under IIS 10. Initially, the goal was to return a few database records in JSON, like a web service. However, to narrow the field of search for the error, I have changed the app...
Jim S
1

votes
0

answer
201

Views

Can't find SharedResource using Localization in Razor Pages

I've followed a pattern used in Razor Views, but when using Razor Pages it doesn't find the resource. Do I need to implement it differently? Startup.cs: public void ConfigureServices(IServiceCollection services) { services.AddLocalization(o => { o.ResourcesPath = 'Resources'; }); services.AddMvc() ....
TheRuler
1

votes
6

answer
1.1k

Views

How can I keep my model in my View after OnPost?

I'm on a project with .Net Core and I'm using ASP Razor Pages. In my model, I have an OnGet which load all the data I need in my view. public IList Projets { get; set; } public ActionResult OnGet() { Projets = _serviceSelect.getProjets(); return Page(); } Then, in my OnPost which is activated when I...
Thomas
1

votes
0

answer
183

Views

kendo UI asynchronous uplaod on Razor Page returns 404

I am trying to use Kendo UI async upload on Razor Page (No controller) But I get 404 error Index.cshtml page- Review Type @(Html.Kendo().Upload() .Name('files') .Async(a => a .Save('Index?handler=Save', 'UploadManagement') .Remove('Remove', 'UploadManagement/Index') .AutoUpload(true) ) ) Upload I...
NKM
1

votes
0

answer
269

Views

Scaffolding Error Microsoft.EntityFramework

I am currently learning how to work with Razor Pages using the following tutorial on Microsoft's Website: Getting Started with Razor Pages in ASP.NET Core In the Add a Model section of the tutorial, it shows how to Scaffold using the Command Prompt. However, upon executing the command, I am met w...
OPM eStudio
1

votes
0

answer
59

Views

How to select Razor Pages from one of many Razor Class Library dlls?

Requirement 1: I have a few Razor Class Libraries namely MyFeature1.dll, MyFeature2.dll, MyFeature3.dll which all have the same file structure and files but the content vary by images, colors, fonts only. NB. I purposefully don't want to create one MyFeatures.dll with different Areas\Features\Pages...
1

votes
1

answer
181

Views

ASP.Net Core Identity Question marks instead of letters

The thing is that when I try to use Russian letters in Identity pre-made pages they just doesn't work. They look like this. I'm using Razor Pages btw. This is _LoginPartial.cshtml for example @using Microsoft.AspNetCore.Identity @using AIProbe0.Data @inject SignInManager SignInManager @inject UserM...
DVice
1

votes
0

answer
135

Views

How to use Razor for Angular Template with prerendering

I'd like to use the power or Razor syntax in my Angular 4 views with server prerendering. As I understand it from many past questions, doing this is trivial without server prerendering, but with the new built-in functionality for this in ASP.NET Core 2, it doesn't seem to work. Is this even possib...
pbarranis
1

votes
1

answer
116

Views

Authorization in ASP.NET Core 2.0 via openid provider

I'm having probles with passing claims from external identity to local one. The application is basically the QuickBooksASPNetCore2 Demo with added openid identity provider. Everything seams to work, except the [Authorize(Role = 'some_role')] on test Razer page. This is the code that is doing the lo...
Eugen
1

votes
1

answer
250

Views

How to set custom routing for ASP NET CORE Identity 2.1 , extending class libraries

I have an application that only does log in. its part of a multi-subdomain app. sub1.domain.com sub2.domain.com login.domain.com we send users to login domain for authentication. To make the url simple we always had the login page set as home page. after upgrading to the new identity 2.1, we have pr...
Webly Speaking
1

votes
1

answer
394

Views

Asp.net core bootstrap tabs issue

I have in a razor page the following bootstrap tab layout: overview Profil Bla overview Profil bla All working fine, except: How can i call the same page with a different tab and content active? Obviously if i do a return RedirectToAction('Edit', 'Profil'); to the same view and controller method i...
SunnySonic
1

votes
1

answer
420

Views

RazorPages: Model does not get instantiated in Partial with Page Model

Im testing out RazorPages and .Net Core 2.1 I have just taken a new project template and have created a Partial. These are relevant/added contents of the files. My problem is 1) Immediate problem: In the partial: OnGetAsync (nor public void OnGet()) does not get called. and I get a NullReference-ex...
Cowborg
1

votes
1

answer
591

Views

Using Razor Pages coredotnet how can I load a partial view via ajax

In using Razor pages, it is simple to use partial using @Html.Partial(..). However, when a drop down changes, I want to refresh part of the view - the part rendered by the partial view. I have searched lots, and found answers such as: https://github.com/aspnet/Razor/issues/2073 where they say parti...
Simon
1

votes
1

answer
1.2k

Views

ASP.NET Core Razor Pages | can partial views have page models

I have a partial view called _Subscribe.cshtml Is it okay for partial views to have a page model _Subscribe.cshtml.cs? I want to allow people who visit my website to be able to subscribe to keep up-to-date with any changes to my website. The subscribe form will be in the _Subscribe.cshtml and this p...
1

votes
2

answer
475

Views

Form Action Tag Helper in Razor Pages doesn't redirect me

I'm trying to do a search box. When I press the search button nothing happens. I want to redirect to /Search&searchTerm=il. Also how to get what's typed in the input box and add it to the asp-route-searchTerm?
Iliyan Ivanov
1

votes
1

answer
53

Views

validate html tag input for a textbox control globally in web.config file

I want to restrict the user giving html tags as input. so how can i handle it globally in web.config file for my Asp.Net MVC project. I have used ValidateInput(false), but it completely allowing the html tags to save in db.
V.SSL
1

votes
0

answer
153

Views

How do I render a view from a razor page handler?

I have a collection of items in which I need the user to be able to add and remove them without actually making a post. The page gets rendered with 2 items by default. The user can then add and remove as they would like. Then, when they finish, there's a submit button that will trigger the post. I...
James
1

votes
1

answer
1.4k

Views

Redirect to another page from _Layout.cshtml

How to redirect to another page within the _layout.cshtm page in asp.net core razor. I am doing the verification and user is logged in, if not it will be redirected to another page. @using Microsoft.AspNetCore.Identity @using CronoParque.Model @inject SignInManager SignInManager @inject UserManager...
Renato
1

votes
0

answer
22

Views

Why do I get correct join with one table and not another when using VS 2017 and .net core 2.1

Disclaimer: I'm a newbie to Razor Pages and MVC but I'm very familiar with related databases (MS Access) and have a basic knowledge of SQL. I have three tables in a Razor Pages Core 2.1 Database-First solution with VS 2017. The models are Advertisement, State, and AbbrvXref. Advertisement and Sta...
John Thurow
1

votes
1

answer
23

Views

Customize view paths .net core 2.1

I'm trying to configure my core application to add the solution name to the name/path of all views when it compiles/precompiles: Original: Views/Home/index.cshtml what I want is: MyApplicationName/Views/Home/index.cshtml I found a few articles including one from Samuele that explains on how to do th...
1

votes
0

answer
756

Views

Error „No migrations were applied. The database is already up to date“

I'm building a web app using razor pages, and EF with SQLite. I'm developing under Linux with the CORE SDK. After adding an initial migration without problems dotnet ef migrations add InitialCreate. When I update the database I get a message saying No migrations were applied. The database is alread...
moha zayani
1

votes
1

answer
145

Views

How to redirect to ASP.NET Ideneity login page?

Using ASP.NET Identity, if I want to construct an element that links to the Login page I can use Razor Helpers and some magic strings: Login (Not the question at hand, but I'd be happy if someone would tell me why this convoluted collection of magic strings is somehow better than hardcoding the '/I...
1

votes
0

answer
115

Views

How to resolve “The type 'System.Object' is defined in an assembly that is not referenced”

I don't know why I am getting this error. I have looked at questions with similar title but none of them seems to help. web.config Tried: deleted .vs folder and rebuild change port no
codegrid
1

votes
2

answer
61

Views

Need CSS Change in ViewLayout - Bootstrap 4

I am trying to get to practicing with React in ASP.NET. However, I noticed that the latest Bootstrap 4 doesn't appear to come with the same navbar classes after doing some research, which results in the following screen below when I run my project and reach the Index file: In light of the fact that...
Kieran Ojakangas
1

votes
1

answer
130

Views

.Net Core starter template bootstrap layout similar to bootstrap homepage [closed]

I would like to modify the microsoft .net core starter razor pages template to resemble what is here: https://getbootstrap.com/docs/4.1/about/overview/ I've been trying to modify my layout page based on the source html on the link above, but I'm not having much luck. Right now, my side nav and sear...
mo_maat

View additional questions