Determine the URL hostname without using HttpContext.Current?

后端 未结 4 1700
孤独总比滥情好
孤独总比滥情好 2021-02-19 04:32

Using the current request I can get the URL hostname with:

HttpContext.Current.Request.Url.Host

But - I need to determine the URL hostname with

4条回答
  •  失恋的感觉
    2021-02-19 04:45

    If you know the host at the moment you're setting up the event handler then you should be able to do something like (code not actually tested):

    string host = HttpContext.Current.Request.Url.Host;
    var dep = new SqlDependency(cmd);
    dep.OnChange += ((sender, args) =>
    {
        DoStuff(host);
    });
    

提交回复
热议问题