Hello I need your..i am new in web: i have HTML
this is my Controller :
string hn;
hn = Content($"{account.HostName}").ToString();
now when debug hn is null. no value pass by html
Hello I need your..i am new in web: i have HTML
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mohamed Azarudeen ZRank #297 · 8.5K reputationPosted Jun 1, 2023, 3:47 AM EDT
There are a few possible reasons why
hncould be null:Ensure that the
accountobject is properly initialized and contains theHostNamefield with a value. You may need to check how theaccountobject is being created or populated.Check if the
HostNamefield is accessible within theaccountobject. Verify that it is a public property or has a public getter method.Ensure that the
Contentmethod is correctly retrieving the value fromaccount.HostName. Verify that theContentmethod is functioning as expected and returning the correct value.Check if the
Contentmethod is handlingnullvalues correctly. Ifaccount.HostNameisnull, theContentmethod might not be returning a valid value.Rolando Puno137 reputationPosted Jun 1, 2023, 3:58 AM EDT
Hello this my HTML file:
i wanted to pass : id="hostname" to C#.net home Controller, pls help ho can i do
public ActionResult LoginEUA(LoginInfo account)
{
string hn;
hn = Content($"{HostName}").ToString();
}
Rajkiran SwainRank #165 · 14.4K reputationPosted Jun 1, 2023, 12:00 PM EDT
Controller
public ActionResult ActionName(string hostname) { string hn = hostname; // Use the value of hn as needed return View(); }HTML form:
tags and has the correct class attribute (form-horizontal).nameattribute of the form (name="HnForm") is correctly set.account.HostNamevalue you want to pass to the controller.JavaScript file (HostName.js):
account.HostNamecorrectly and setting it in the HTML element with the idhostname.tag.Controller:
account.HostName.