Saturday, June 19, 2021

MVC HttpRuntime class

What is application domain? and how can you get information about the current application domain?
The following example demonstrates how to get properties of the current application domain and display them to the browser by the help of the HttpRuntime class.

using System;
using System.Text;
using System.Web;
using System.Web.Mvc;

namespace WebAppHttp.Controllers
{
    public class HomeController : Controller
    {
        public string Index()
        {
            StringBuilder sb = new StringBuilder();
            String nl = "
"; sb.Append("AppDomainAppId = " + HttpRuntime.AppDomainAppId + nl); sb.Append("AppDomainAppPath = " + HttpRuntime.AppDomainAppPath + nl); sb.Append("AppDomainAppVirtualPath = " + HttpRuntime.AppDomainAppVirtualPath + nl); sb.Append("AppDomainId = " + HttpRuntime.AppDomainId + nl); sb.Append("AspInstallDirectory = " + HttpRuntime.AspInstallDirectory + nl); sb.Append("BinDirectory = " + HttpRuntime.BinDirectory + nl); sb.Append("ClrInstallDirectory = " + HttpRuntime.ClrInstallDirectory + nl); sb.Append("CodegenDir = " + HttpRuntime.CodegenDir + nl); sb.Append("IsOnUNCShare = " + HttpRuntime.IsOnUNCShare.ToString() + nl); sb.Append("MachineConfigurationDirectory = " + HttpRuntime.MachineConfigurationDirectory + nl); var data = sb.ToString(); return data; } } }



No comments:

Post a Comment

Hot Topics