C
C#14mo ago
NullReference

✅ Redirect ASP.NET

Hi. I would like to insert styles on the page first, and then output a JSON file, but I don't understand how to do it.
30 Replies
NullReference
NullReference14mo ago
I tried everything I knew.
x0rld
x0rld14mo ago
why you want to load css like that ? 🤔 why not use the css injector classic in asp.net core ?
NullReference
NullReference14mo ago
I am beginner. I don't know what is this😅
x0rld
x0rld14mo ago
ah you are using razor for the views ?
NullReference
NullReference14mo ago
ok, i will try it :/
x0rld
x0rld14mo ago
it's like that for razor ( the .cshtml files )
@section styles {
<link href="@Url.Content("~/your/path/index.css")" rel="stylesheet" type="text/css" />
}
@section styles {
<link href="@Url.Content("~/your/path/index.css")" rel="stylesheet" type="text/css" />
}
NullReference
NullReference14mo ago
I am just learning controllers. I haven't used view yet))
x0rld
x0rld14mo ago
it's an api ? 🤔
NullReference
NullReference14mo ago
idk😅 I found a website for studying ASP.NET . And first they teach you how to use controllers
x0rld
x0rld14mo ago
can you give me the link
NullReference
NullReference14mo ago
ASP.NET Core MVC | Полное руководство
Полное руководство по созданию веб-приложений с помощью фреймворка ASP.NET Core MVC на языке программирования C#
NullReference
NullReference14mo ago
its russian site so, I am also from Russia😅
x0rld
x0rld14mo ago
np thanks to translator 😂
NullReference
NullReference14mo ago
))
x0rld
x0rld14mo ago
in the chapter 1 there is views 🤔 https://metanit.com/sharp/aspnetmvc/1.3.php
NullReference
NullReference14mo ago
But it does not describe how to work with them
x0rld
x0rld14mo ago
oh yeah oh ok you are in the second chapter ?
NullReference
NullReference14mo ago
yeah I know that since I am nobody does. But I just wanted to do something of my own with what I know now.
x0rld
x0rld14mo ago
public class HomeController : Controller
{
public string Index()
{
string tomJson = JsonSerializer.Serialize(tom,jsonSettings);
return $"{yourStyleContent}{tomJson}";
}
public class HomeController : Controller
{
public string Index()
{
string tomJson = JsonSerializer.Serialize(tom,jsonSettings);
return $"{yourStyleContent}{tomJson}";
}
you can do something like that @NullReference you understand ?
NullReference
NullReference14mo ago
i'm tryinng it now one sec
NullReference
NullReference14mo ago
NullReference
NullReference14mo ago
error 406
x0rld
x0rld14mo ago
show me where did your write the code
NullReference
NullReference14mo ago
I fixed the bug issue, but now it looks like this
x0rld
x0rld14mo ago
oh 🤔 let me try something
NullReference
NullReference14mo ago
I could!
Response.ContentType = "text/html";
Response.ContentType = "text/html";
NullReference
NullReference14mo ago
x0rld
x0rld14mo ago
maybe oh yeah didn't think about that xD
NullReference
NullReference14mo ago
Thanks!!! You are the best)))
x0rld
x0rld14mo ago
👌 you can close with /close
Want results from more Discord servers?
Add your server
More Posts