Last post Jul 11, 2019 08:52 AM by PatriceSc
Jul 11, 2019 07:49 AM|ahmedbarbary|LINK
can I use string function inside controller and replace action or not on asp.net core 2.1 ?
on asp.net core 2.1 when link to any web application i use default route
can i use function return string as function ShowText() after controller
meaning employee/ShowText or must use Action Result ?
and when route to link employee/ShowText
are this route will work ?
What I have tried:
public string ShowText()
string show = "welcom ";
return show ;
Jul 11, 2019 08:14 AM|PatriceSc|LINK
And what happens ? How do you call that ? Have a look at https://docs.microsoft.com/en-us/aspnet/core/web-api/action-return-types?view=aspnetcore-2.2
Maybe you are trying to do something such as a view component ? See https://docs.microsoft.com/en-us/aspnet/core/mvc/views/view-components?view=aspnetcore-2.2
If it doesn't help explain perhaps regardless of any technical consideration what you are trying to do. For now my understanding is that your utimate goal is to render a specific snippet of markup inside pages(s) ? BTW if found on most if not all pages you
could also have a look at "layout pages".
Jul 11, 2019 08:19 AM|ahmedbarbary|LINK
THANK YOU FOR reply
when make link controller/stringfunction this will work or not
Jul 11, 2019 08:52 AM|PatriceSc|LINK
If sending an http request to this controller/action you'll get this text as a response. What if you just try in your browser using <site>/Employee/ShowText ? is this what you mean by "make link"?
Still it seems to be really overkill to me if your intent is really to get some small text even all along even with a user name.