Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
306 views
in Technique[技术] by (71.8m points)

asp.net - VB.net UploadFile Request.Files.AllKeys always empty

I have seen this question many times on the web but never with simple code and clear answers Below is my code of the winForm and the webASPX with no extraneous code I am sure I am missing something I am trying to send a file from a WinForm program to a web server and there are never any files I get the beep but it never hits the stop Request count is always zero

`

Imports System.Net

Public Class Form1
    Public ServerURL As String = "http://localhost:50918"

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim myWebClient As New WebClient
        Dim responseArray As Byte()
        Dim Filename As String = "C:Tempmyfile.txt"

        responseArray = myWebClient.UploadFile(ServerURL & "/Webform1.aspx", Filename)

    End Sub
End Class


    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication6.WebForm1" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server" enctype="multipart/form-data">
            <div>
            </div>
        </form>
    </body>
    </html>

    Public Class WebForm1
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Beep()
            Debug.Print(Request.Files.Count) 
            For Each f As String In Request.Files.AllKeys
                Stop
            Next
    
        End Sub
    
    End Class

`


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...