System.InvalidOperationException | IServiceCollection.AddRazorPages | Resolved

Published: 21 September 2022
on channel: Digital Knack
3,590
48

In this video I have resolved the following error that you might face while making an application in asp.net mvc and using Razor Pages in your application.
The error is:


System.InvalidOperationException: 'Unable to find the required services. Please add all the required services by calling 'IServiceCollection.AddRazorPages' inside the call to 'ConfigureServices(...)' in the application startup code.'

The solution is very simple:

You need to add

builder.Services.AddRazorPages();

After

builder.Services.AddControllersWithViews();

in your program.cs or startup.cs class.

I am using .net 6.0 so I have only Program.cs class.
In previous versions, like 5.0 or 3.1 you need to add this in startup.cs class.
==================================================
Thanks for watching,
Please subscribe my channel.
==================================================
If you have any questions or queries, write them in comments below
or mail me at:
[email protected]
==================================================
Audio Used in Video:
The Coldest Shoulder
Credits: YouTube free music library
==================================================


Watch video System.InvalidOperationException | IServiceCollection.AddRazorPages | Resolved online without registration, duration hours minute second in high quality. This video was added by user Digital Knack 21 September 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 3,590 once and liked it 48 people.