c# - Dynamically display welcome string in "Your logo here" -


what trying dynamically display welcome string of company name based on url area of "your logo here" in mvc 4 internet applcation. if in http://aaa.com wanna welcome aaa

what have done replace

<p class="site-title">@html.actionlink("your logo here", "index", "home")</p> 

to

@html.partial("_company") 

and in _company view @html.renderaction( "company", "home") , in homecontroller use

public actionresult hospitalinfo()         {            var url = geturlmethod();            return partialview("_company ", new { name = url });         } 

can please let me know if idea correct or not ? or can me improve method. currently, code not work @ all...

if you're interested in string, don't need spin separate partial view own controller action. create helper function, manipulate url in there, , call function directly view.

.cs:

public static string getcustomwelcomestring() {     string customstring;      // use system.web.httpcontext.current.request.url here cool stuff      return customstring; } 

.cshtml:

<p class="site-title">@myclass.getcustomwelcomestring()</p> 

for more architecturally clean solution, consider pre-calculating title in main controller action , returning model field, view can consume directly using @model.customwelcomestring or that..


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -