I am writing multitenant based application and I want to load custom view from storage base on url(tenant).
I type https://corporate.myapp.local/ in browser but in FileExistsmethod HttpContext.Current.Request.Url give me http://127.0.0.1/ it does not tell me which domain is this so i can get file base on domain and resolve tenantid
public class ViewPathProvider : VirtualPathProvider, ICustomVirtualPathProvider
{
VirtualPathProvider ICustomVirtualPathProvider.Instance => this;
private readonly ILogger _logger;
private readonly IThemeService _themeService;
private readonly ISellutionSession _sellutionSession;
public ViewPathProvider(ILogger logger, IThemeService themeService, ISellutionSession sellutionSession)
{
_logger = logger;
_themeService = themeService;
_sellutionSession = sellutionSession;
}
public override bool FileExists(string virtualPath)
{
_logger.Log($"CurrentCompanyId: {_sellutionSession.GetCurrentCompany(HttpContext.Current.Request.Url).CompanyId}");
var isViewExist = Pages.IsExistByVirtualPath(virtualPath);
return isViewExist || Previous.FileExists(virtualPath);
}
You need to set up your Development environment to be able to accept sub domains, This can be accomplished by editing the applicationHost.config file and the host file on the machine.
need to change how IIS Express runs your development environment.
In Visual Studio 2015, right-click on the solution file.
Select 'Open Folder in File Explorer'
Go to the containing folder and look for a .vs folder.
Inside, there will be a config folder containing an applicationhost.config file.
Open it in your favorite text editor (I use Notepad++)
Under the Configuration/system.applicationHost/Sites, you should see your site in bindings with a port and localhost.
Duplicate this line and add your subdomain to this binding.
Save this file and reload your project.
Host File need to head to our Hosts file to modify that as well.
Go to C:\Windows\System32\Drivers\Etc in File Explorer. Open the HOSTS file (it has no extension) At the bottom of the hosts file, add the following two lines.
Save the file.
you need to give Visual Studio 2015 Administrative rights to use subdomains.
Now we can run our Visual Studio and see our subdomain actually run.st:3892
Here is a link to help you.