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, duration hours minute second in high quality that is uploaded to the channel Digital Knack 21 September 2022. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 3,590 times and liked it 48 visitors.