Showing posts with label RESTFUL API. Show all posts
Showing posts with label RESTFUL API. Show all posts

Friday, June 07, 2019

"There is already an open DataReader associated with this Command which must be closed first."

This can happen if you execute a query while iterating over the results from another query. I ran into this issue when I called another async call while I was executing one result.

public async Task<IActionResult> GetTicketsInventory(int customerID, int accountID)
        {
            var service_response = await this.ticketsService.GetTicketsInventory(customerID, accountID);
            List<TicketsInventoryCO> items = service_response.Response.ToConvert();

               // this is my second call where i am trying to get results based on some condition
               // to get customer names
                var customer_response = await this.customerService.GetAllMobilityCustomers();

            return ProcessServiceResponse(
                apiContext,
                service_response,
                items,
                null);

        }

This can be easily solved by allowing MARS in your connection string. Add MultipleActiveResultSets=true to the provider part of your connection string (where Data Source, Initial Catalog, etc. are specified). Sample connection string

 "CoreCS": "Data Source=xxx.xxx.xxx.xxx;Initial Catalog=Mobility;Integrated Security=False;User Id=sa; Password=xxxxxx;Max Pool Size=20; Connection Timeout=10;MultipleActiveResultSets=true;",

Monday, September 12, 2016

405 - HTTP verb used to access this page is not allowed

We get the above error when we use PUT verb when we access RESTFUL web services.

For this to work, The web site had to continue to enable WebDAV, but the web application needed to turn it off in order to support PUT and DELETE in its REST API.

Below are the approaches I followed to solve my problem.

Procedure 1:

  1. In the IIS Manager, select the application that needs to support PUT.  
  2. In the Features View, find WebDAV Authoring Rules.  Double-click it, or select Open Feature from the context menu (right-click).
  3. In the Actions pane, find and click on WebDAV Settings....
  4. In the WebDAV Settings, find Request Filtering Behavior, and under that, find Allow Verb Filtering.  Set Allow Verb Filtering to False. 2016-09-14_1402
  5. In the Actions pane, click Apply.

Procedure 2:

1. Go to IIS Manager.
2. Click on your app.
3. Go to "Handler Mappings".
4. In the feature list, double click on "WebDAV".

2016-09-14_1411
5. Click on "Request Restrictions".
6. In the tab "Verbs" select "All verbs" .

2016-09-14_1412
7. Press OK.

Hope this helps!