开发者

Asp .Net MVC File Upload in Development Server with JUpload

I'm using JUpload (http://jupload.sourceforge.net/) to process file uploading, as I need the possibility to select a folder and upload all the files within. Well anyways, my problem is that with the same code, on the IIS7 file upload is working and with the Asp Net Development Server (of MS Visual Studio 2010) the upload will fail (Error message: "The string '^SUCCESS$' was not found in the response body").

My code looks like this:

        public ActionResult UploadTest(HttpPostedFileBase file)
    {
        Debug.WriteLine("ContentType: " +Request.ContentType + " HttpMethod: " + Request.HttpMethod);
        Debug.WriteLine("File is null ?: " + (file == null));

        Response.StatusCode = 200;

        if (file != null)
        {
            Debug.WriteLine("filename: " + file.FileName + " size: " + file.ContentLength + " Type: " + file.ContentType);
            Response.Write(file.FileName);
        }

        Response.Write("\n");
        return Content("SUCCESS");
    }

The log of JUpload shows this in the development server:

_http://paste-it.net/public/j6608f6/

and this is from IIS7

http://paste-it.net/public/f51cbb7/

From whatI see the files get passed throught the controller, but in the Development server there seems to be an additional 开发者_StackOverflow社区HTTP Code 100 which is introducing the error.

I'd be happy for any suggestions :)


OK, so if you want to do like me, here you go, if you're willing to recompile the applet and sign it... the main steps:

  • Download the file I submitted here link text
  • Get the project source using subversion (see project's doc).
  • Get JDK SE installed and environment variable JAVA_HOME defined, JAVA_HOME\bin added to your path
  • Get NetBeans installed
  • Get Maven installed, and environment variables M2_HOME and M2 defined, M2 added to your path
  • Create a certificate using keytool (see JUpload's "how to sign" page) but at the end of key generation command line, add "-keystore mykeystore.jks" so that the private key resides in a file
  • Create a settings.xml file according to JUpload's "how to compile" page and put it in your user profile ".m2" directory (I had to create it). See in your Maven install folder, "conf" subdir, for settings.xml global structure.

So in your user settings.xml you would have : <jupload.keystore.alias>jupload</jupload.keystore.alias> <jupload.keystore.filename>d:\keystore\mykeystore.jks</jupload.keystore.filename> <jupload.keystore.storepass>[password you used to generate private key]</jupload.keystore.storepass>

And you're done after launching project recompilation in Netbeans. Jar resides in project's "target" folder.

Now, use "DefaultUploadPolicy2" for "uploadPolicy" applet parameter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜