c# - How to pass string value with length more than '500' -
and here webservice
[httpget] [actionname("getimage")] public string getimage(string base64string, string imgname) { try { using (phnetworkentities context = new phnetworkentities()) { pic pic = new pic(); pic.path = base64string; pic.picname = imgname; context.pics.add(pic); context.savechanges(); return "success"; } } catch (dbentityvalidationexception ex) { // retrieve error messages list of strings. var errormessages = ex.entityvalidationerrors .selectmany(x => x.validationerrors) .select(x => x.errormessage); // join list single string. var fullerrormessage = string.join("; ", errormessages); // combine original exception message new one. var exceptionmessage = string.concat(ex.message, " validation errors are: ", fullerrormessage); // throw new dbentityvalidationexception improved exception message. throw new dbentityvalidationexception(exceptionmessage, ex.entityvalidationerrors); } }
i'm not sure if code problem or web.config , here web.config
<?xml version="1.0" encoding="utf-8"?> <configuration> <configsections> <section name="entityframework" type="system.data.entity.internal.configfile.entityframeworksection, entityframework, version=5.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false" /> </configsections> <connectionstrings> <add name="phnetworkentities" connectionstring="metadata=res://*/models.model1.csdl|res://*/models.model1.ssdl|res://*/models.model1.msl;provider=system.data.sqlclient;provider connection string="data source=androiddb;initial catalog=phnetwork;integrated security=true;multipleactiveresultsets=true;application name=entityframework"" providername="system.data.entityclient" /></connectionstrings> <appsettings> <add key="webpages:version" value="2.0.0.0" /> <add key="webpages:enabled" value="false" /> <add key="preserveloginurl" value="true" /> <add key="clientvalidationenabled" value="true" /> <add key="unobtrusivejavascriptenabled" value="true" /> </appsettings> <system.web> <compilation debug="true" targetframework="4.5" /> <httpruntime targetframework="4.5" maxquerystringlength="2097151" maxurllength="2097151" maxrequestlength="2097151" /> <authentication mode="none" /> <pages> <namespaces> <add namespace="system.web.helpers" /> <add namespace="system.web.mvc" /> <add namespace="system.web.mvc.ajax" /> <add namespace="system.web.mvc.html" /> <add namespace="system.web.optimization" /> <add namespace="system.web.routing" /> <add namespace="system.web.webpages" /> </namespaces> </pages> <profile defaultprovider="defaultprofileprovider"> <providers> <add name="defaultprofileprovider" type="system.web.providers.defaultprofileprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" applicationname="/" /> </providers> </profile> <membership defaultprovider="defaultmembershipprovider"> <providers> <add name="defaultmembershipprovider" type="system.web.providers.defaultmembershipprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" enablepasswordretrieval="false" enablepasswordreset="true" requiresquestionandanswer="false" requiresuniqueemail="false" maxinvalidpasswordattempts="5" minrequiredpasswordlength="6" minrequirednonalphanumericcharacters="0" passwordattemptwindow="10" applicationname="/" /> </providers> </membership> <rolemanager defaultprovider="defaultroleprovider"> <providers> <add name="defaultroleprovider" type="system.web.providers.defaultroleprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" applicationname="/" /> </providers> </rolemanager> <sessionstate mode="inproc" customprovider="defaultsessionprovider"> <providers> <add name="defaultsessionprovider" type="system.web.providers.defaultsessionstateprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" /> </providers> </sessionstate> </system.web> <system.webserver> <validation validateintegratedmodeconfiguration="false" /> <handlers> <remove name="extensionlessurlhandler-isapi-4.0_32bit" /> <remove name="extensionlessurlhandler-isapi-4.0_64bit" /> <remove name="extensionlessurlhandler-integrated-4.0" /> <add name="extensionlessurlhandler-isapi-4.0_32bit" path="*." verb="get,head,post,debug,put,delete,patch,options" modules="isapimodule" scriptprocessor="%windir%\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll" precondition="classicmode,runtimeversionv4.0,bitness32" responsebufferlimit="0" /> <add name="extensionlessurlhandler-isapi-4.0_64bit" path="*." verb="get,head,post,debug,put,delete,patch,options" modules="isapimodule" scriptprocessor="%windir%\microsoft.net\framework64\v4.0.30319\aspnet_isapi.dll" precondition="classicmode,runtimeversionv4.0,bitness64" responsebufferlimit="0" /> <add name="extensionlessurlhandler-integrated-4.0" path="*." verb="get,head,post,debug,put,delete,patch,options" type="system.web.handlers.transferrequesthandler" precondition="integratedmode,runtimeversionv4.0" /> </handlers> <security> <requestfiltering> <requestlimits maxquerystring="5000000" maxallowedcontentlength="500000000" /> </requestfiltering> </security> </system.webserver> <runtime> <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentassembly> <assemblyidentity name="system.web.helpers" publickeytoken="31bf3856ad364e35" /> <bindingredirect oldversion="1.0.0.0-2.0.0.0" newversion="2.0.0.0" /> </dependentassembly> <dependentassembly> <assemblyidentity name="system.web.mvc" publickeytoken="31bf3856ad364e35" /> <bindingredirect oldversion="1.0.0.0-4.0.0.0" newversion="4.0.0.0" /> </dependentassembly> <dependentassembly> <assemblyidentity name="system.web.webpages" publickeytoken="31bf3856ad364e35" /> <bindingredirect oldversion="1.0.0.0-2.0.0.0" newversion="2.0.0.0" /> </dependentassembly> <dependentassembly> <assemblyidentity name="entityframework" publickeytoken="b77a5c561934e089" /> <bindingredirect oldversion="1.0.0.0-5.0.0.0" newversion="5.0.0.0" /> </dependentassembly> <dependentassembly> <assemblyidentity name="webgrease" publickeytoken="31bf3856ad364e35" /> <bindingredirect oldversion="1.0.0.0-1.3.0.0" newversion="1.3.0.0" /> </dependentassembly> </assemblybinding> </runtime> <entityframework> <defaultconnectionfactory type="system.data.entity.infrastructure.sqlconnectionfactory, entityframework" /> </entityframework> </configuration>
please advice . thank time .
modify "getimage" , try calling web service sending string len < 500
then can see problem it's ef problem , not web service problem.
[actionname("getimage")] public string getimage(string base64string, string imgname) { try { using (phnetworkentities context = new phnetworkentities()) { pic pic = new pic(); pic.path = new string('*', 502); // modify!! fails!!! pic.picname = imgname; context.pics.add(pic); context.savechanges(); return "success"; } } catch (dbentityvalidationexception ex) { // same question... } }
maybe it's auto-generated code. check design of table "pics" in database, prop of column path nvarchar(500) or varchar(500) ?
or maybe search in "phnetworkentities" max length assigned pic.path
Comments
Post a Comment