title: The device is not ready error when typing url on browser
body: <p>I am using Stripe payment gateway for Ecommerce transaction. To communicate I have to use webhook url means I will provide a url so that they can commincate with us.
  I created a controller and Action which is <code>[AllowAnonymus]</code>. When I run application locally and type controller and action on browser then it hit the action. But when I deployed on my test server and do the same it gives the following error </p>
  
  <blockquote>
    <p>Server Error in '/' Application.
    The device is not ready.</p>
  </blockquote>
  
  <p><strong>Stack Trace:</strong> </p>
  
  <pre><code>[IOException: The device is not ready.
  ]
     System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +14840940
     System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +1430
     System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +211
     System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) +210
     System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost) +87
     SchoolManagement.DTO.Entities.OrderItem.SavePartialCharge(String invoiceData) in c:\Atlassian\Bamboo-home\xml-data\build-dir\SMS-PPINBOX-JOB1\SchoolDTO\Entities\OrderItem.cs:185
     SchoolWeb.Controllers.StripeWebhookController.GetStripeResponse() in c:\Atlassian\Bamboo-home\xml-data\build-dir\SMS-PPINBOX-JOB1\SchoolWeb\Controllers\StripeWebhookController.cs:24
     lambda_method(Closure , ControllerBase , Object[] ) +79
     System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +270
     System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass39.&lt;BeginInvokeActionMethodWithFilters&gt;b__33() +120
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4f.&lt;InvokeActionMethodFilterAsynchronously&gt;b__49() +452
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass37.&lt;BeginInvokeActionMethodWithFilters&gt;b__36(IAsyncResult asyncResult) +15
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass2a.&lt;BeginInvokeAction&gt;b__20() +33
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass25.&lt;BeginInvokeAction&gt;b__22(IAsyncResult asyncResult) +240
     System.Web.Mvc.&lt;&gt;c__DisplayClass1d.&lt;BeginExecuteCore&gt;b__18(IAsyncResult asyncResult) +28
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4.&lt;MakeVoidDelegate&gt;b__3(IAsyncResult ar) +15
     System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4.&lt;MakeVoidDelegate&gt;b__3(IAsyncResult ar) +15
     System.Web.Mvc.&lt;&gt;c__DisplayClass8.&lt;BeginProcessRequest&gt;b__3(IAsyncResult asyncResult) +42
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4.&lt;MakeVoidDelegate&gt;b__3(IAsyncResult ar) +15
     System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +288
  </code></pre>
  
  <p>Can any one help me to resolve this issue.</p>
  
  <p>The following code written in Action:</p>
  
  <pre><code>public class StripeWebhookController : BaseController
      {
          //
          // GET: /StripeWebhook/
  
            [AllowAnonymous]
          public JsonResult GetStripeResponse()
          {
              Stream req = Request.InputStream;
              req.Seek(0, System.IO.SeekOrigin.Begin);
              string json = new StreamReader(req).ReadToEnd();
              DTO.OrderItem.SavePartialCharge(json);
              return Json("", JsonRequestBehavior.AllowGet);
          }
  
      }
  </code></pre>
  
  <p>Adding the method SavePartialCharge</p>
  
  <pre><code>public static String SavePartialCharge(string invoiceData)
          {
              try
              {
  
                  string stripeEventType = BL.PaymentGateway.StripeReturn.GetStripeType(invoiceData);
                  var obj = JObject.Parse(invoiceData);
                  var dataObj = obj.SelectToken("data.object");
                  var subscriptionID = dataObj.SelectToken("subscription").ToString();
                  var customerID = dataObj.SelectToken("customer").ToString();
                  var chargeID = dataObj.SelectToken("charge").ToString();
                  var amount = Convert.ToDecimal(!dataObj.SelectToken("subtotal").ToString().IsNullOrEmpty() ?dataObj.SelectToken("subtotal").ToString() : "0");
  
                  using (var db = new SchoolEntities())
                  {
                      switch (stripeEventType)
                      {
  
                          case "invoice.payment_failed":
                              var resultorderFailed =
                                  db.OrderItems.Where(oi =&gt; oi.MerchantServiceSubscriptionID == subscriptionID)
                                      .Select(oi =&gt; new {oi.ID, oi.Order.CreditCard4Digits})
                                      .FirstOrDefault();
                              if (resultorderFailed != null)
                                  OrderItemInstallment.AddOrderItemInstallment(db, resultorderFailed.ID, amount,
                                      resultorderFailed.CreditCard4Digits, chargeID, false);
                              return "";
                          case "invoice.payment_succeeded":
                              var resultOrderSucceed =
                                  db.OrderItems.Where(oi =&gt; oi.MerchantServiceSubscriptionID == subscriptionID)
                                      .Select(oi =&gt; new {oi.ID, oi.Order.CreditCard4Digits, oi.TotalInstallments})
                                      .FirstOrDefault();
                              if (resultOrderSucceed != null)
                              {
                                  OrderItemInstallment.AddOrderItemInstallment(db, resultOrderSucceed.ID, amount,
                                      resultOrderSucceed.CreditCard4Digits, chargeID, true);
                                  var count =
                                      db.OrderItemInstallments.Count(
                                          oii =&gt; oii.OrderItemID == resultOrderSucceed.ID &amp;&amp; oii.Success);
                                  if (count == resultOrderSucceed.TotalInstallments)
                                      BL.PaymentGateway.StripePaymentGateway.CancelSubscription(customerID,
                                          subscriptionID);
                              }
                              return "";
                      }
                  }
  
              }
              catch (Exception ex)
              {
                  System.IO.File.WriteAllText(@"D:\exception.txt", ex.Message);
              }
              return "";
          }
  </code></pre>