Question: I need to split the String by `numbers` and `.` symbol.
 My String is 

```
"Nagapur82. Nanavade83. Nandur84. Nandurkichi Wadi85."

```

and I want Array of like 

```
[ "Nagapur", "Nanavade", "Nandur", "Nandurkichi Wadi"]

```

Answer: 
Instead of getting `HttpContext`, get `IHtttpContextAccessor` service from DI container (it does not make any sense to pass the `HttpContext` from the startup class):

```
services.AddHttpContextAccessor();
services.AddTransient<RequestInfo>(sp =>
{
    var context = sp.GetService<IHttpContextAccessor>();
    return new RequestInfo(context)
});

```

You can alternatively simplify this problem by introducing an `interface` for `RequestInfo`:

```
public interface IRequestInfo
{
}

public class RequestInfo
{
    private readonly IHttpContextAccessor _httpContextAccessor;

    public RequestInfo(IHttpContextAccessor httpContextAccessor)
    {
        _httpContextAccessor = httpContextAccessor;
    }
}

```

and in `ConfigureServices` method:

```
services.AddHttpContextAccessor();
services.AddScoped<IRequestInfo, RequestInfo>();

```
You just need to register all the dependencies before they are needed as shown below:

```
services.AddHttpContextAccessor();
services.AddTransient<RequestInfo>();

```

Inside the `RequestInfo` class you can ask for `IHttpContextAccessor`

```
public class RequestInfo
{
    private readonly IHttpContextAccessor _httpContext;

    public RequestInfo(IHttpContextAccessor httpContext)
    {
        _httpContext = httpContext;
    }
}

```