Question: How to use ternary condition with style - url tag, between HttpContext.Current.Request.Url.Host and HttpContext.Current.Request.Url.Authority on .aspx page to (want to check is it localhost or not directly)?

Here is example:

```
"div style='<%= "height: 1115px; background-image: url(\"" + "http://" + HttpContext.Current.Request.Url.Host.ToString() +"ImagePath"); background-position: bottom center; background-repeat: no-repeat;" %>'"

```

I want to check if it is localhost then it will take Authority and if not then it must take Host.

Answer: 
this .aspx code (sorry, it's long, I couldn't break it into multiple without breaking syntax):

```
<div style='<%= "height: 1115px; background-image: url(\"http://" + (HttpContext.Current.Request.Url.Host.ToString().Contains("localhost") ? HttpContext.Current.Request.Url.Authority : HttpContext.Current.Request.Url.Host ) + "/" + "path/to/image.jpg" + "\"); background-position: bottom center; background-repeat: no-repeat;" %>'>my_div_content</div>

```

will produce this result:

```
<div style="height: 1115px; background-image: url("http://lc.host.com/path/to/image.jpg"); background-position: bottom center; background-repeat: no-repeat;">my_div_content</div>

```

given that your `ImagePath` variabl contains the real path to your image, you need to replace this line in the div:

```
+ "path/to/image.jpg" + 

```

with this:

```
+ ImagePath + 

```

Don't worry that both `style="` and `url("` contain `"`, it should work anyways. I confirmed this in Chrome.

HTH
Pseudo code:

HttpContext.Current.Request.Url.Contains("localhost") ? ... : ...