0

How to get value from api request in startup ConfigureServices C# mvc .net core 3

string page = HttpContext.Request.Query["page"].ToString();
            string conn = null; 
            string req = ; //I want to get request value
            foreach (ConnectionStringSettings c in System.Configuration.ConfigurationManager.ConnectionStrings)
            {
                if(c.ConnectionString == req)
                {
                    conn = c.ConnectionString;
                }

            }
            services.AddDbContext<ApplicationDbContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString(conn)));
2
  • 2
    ConfigureServices occurs on application initialization. This gets the application ready for use. The executing code does not have access to an http request at this point. Commented Oct 20, 2020 at 13:07
  • See the marked duplicate, I think this is what you are asking for. You just have to extend it to make use of the query string. Commented Oct 20, 2020 at 13:12

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.