The new way to do this (v12.02 and newer) is to let the IPageService take care of this. This works in Dnn and Oqtane. Like this:

var page = GetService<ToSic.Sxc.Web.IPageService>();

The old way which will only work in Dnn is to tell DNN that your code needs jQuery, you must use RequestRegistration. Add this code:

@using DotNetNuke.Framework.JavaScriptLibraries;
@{   JavaScript.RequestRegistration(CommonJs.jQuery);