c# - The device is not ready error when typing url on browser -
i using stripe payment gateway ecommerce transaction. communicate have use webhook url means provide url can commincate us. created controller , action [allowanonymus]. when run application locally , type controller , action on browser hit action. when deployed on test server , same gives following error
server error in '/' application. device not ready.
stack trace:
[ioexception: device 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.<>c__displayclass39.<begininvokeactionmethodwithfilters>b__33() +120 system.web.mvc.async.<>c__displayclass4f.<invokeactionmethodfilterasynchronously>b__49() +452 system.web.mvc.async.<>c__displayclass37.<begininvokeactionmethodwithfilters>b__36(iasyncresult asyncresult) +15 system.web.mvc.async.<>c__displayclass2a.<begininvokeaction>b__20() +33 system.web.mvc.async.<>c__displayclass25.<begininvokeaction>b__22(iasyncresult asyncresult) +240 system.web.mvc.<>c__displayclass1d.<beginexecutecore>b__18(iasyncresult asyncresult) +28 system.web.mvc.async.<>c__displayclass4.<makevoiddelegate>b__3(iasyncresult ar) +15 system.web.mvc.controller.endexecutecore(iasyncresult asyncresult) +53 system.web.mvc.async.<>c__displayclass4.<makevoiddelegate>b__3(iasyncresult ar) +15 system.web.mvc.<>c__displayclass8.<beginprocessrequest>b__3(iasyncresult asyncresult) +42 system.web.mvc.async.<>c__displayclass4.<makevoiddelegate>b__3(iasyncresult ar) +15 system.web.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() +606 system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +288 can 1 me resolve issue.
the following code written in action:
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); } } adding method savepartialcharge
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 => oi.merchantservicesubscriptionid == subscriptionid) .select(oi => 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 => oi.merchantservicesubscriptionid == subscriptionid) .select(oi => 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 => oii.orderitemid == resultordersucceed.id && 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 ""; }
your stacktrace points error streamwriter. according code, there 1 occurence if streamwriter:
catch (exception ex) { system.io.file.writealltext(@"d:\exception.txt", ex.message); } this means, exception occurs , catch block wants log exception local drive. causes exception, because there possibly no drive d. logically, after solved exception, there exception, catch block log.
check test machine, if drive d present (and no cd drive) , iis user account has appropriate permissions.
on sidenote: wouldn't catch exception way. pollutes text file error messages, without stacktrace, timestamps etc. levarage 1 of many logging frameworks out there (nlog example) , make live way easier.
Comments
Post a Comment