Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3335550
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:01:52+00:00 2026-05-18T00:01:52+00:00

I didn’t find any answer on web with vb.net (I find millions of samples

  • 0

I didn’t find any answer on web with vb.net (I find millions of samples with c#)

I translated a sample controller to vb.net but doesn’t upload

My ResimController.vb

<AcceptVerbs(HttpVerbs.Post)>
Public Function Anasayfa(ByVal forms As FormCollection) As ActionResult

    Dim errors As Boolean = False
    If String.IsNullOrEmpty(forms("Resimx")) Then
        errors = True
        ModelState.AddModelError("Resimx", "error")
    Else
        Dim sFileName As String = forms("Resimx")

        Dim file = Request.Files("Resimx")
        ''file' is always null, and Request.Files.Count is always 0 ??? 
        If file IsNot Nothing Then 'This line always returns Nothing
            Dim buf As Byte() = New Byte(file.ContentLength - 1) {}
            'do stuff with the bytes 
            file.InputStream.Read(buf, 0, file.ContentLength)
        Else
            errors = True
            ModelState.AddModelError("Resimx", "error")
        End If
    End If
    If errors Then
        Response.Write("Failed")
        Return View()
    Else
        Response.Write("Success")
        Return View()
    End If

End Function

The Anasayfa.aspx page

<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Anasayfa
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Anasayfa</h2>
    <form method="post" enctype="multipart/form-data" action="">
        <%: Html.ValidationSummary(True)%>
        <%: Html.ValidationMessageFor(Function(model) model)%>
        &nbsp;
        <input id="Resimx" name="Resimx" type="file" />
        <br />
        <br />
        <input id="Submit1" type="submit" value="submit" />
        &nbsp;
    </form>
</asp:Content>
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:01:53+00:00Added an answer on May 18, 2026 at 12:01 am

    The AjaxControlToolkit registration in the beginning of your view and the missing action attribute on your form raise some serious suspicions about your design. It seems that you are trying to use server side controls which is a no-no in ASP.NET MVC because they rely on viewstate and postback model.

    Here’s an example of how you could implement file uploads in MVC:

    Controller:

    <HandleError()> _
    Public Class HomeController
        Inherits System.Web.Mvc.Controller
    
        Function Index() As ActionResult
            Return View()
        End Function
    
        <HttpPost()>
        Function Index(ByVal Resimx As HttpPostedFileBase) As ActionResult
            If Not Resimx Is Nothing Then
                ' A file has been selected => do something with the uploaded file
            End If
            Return View()
        End Function
    End Class
    

    View:

    <%  Using Html.BeginForm("Index", "Home", Nothing, FormMethod.Post, New With { .enctype = "multipart/form-data" })%>
        <input id="Resimx" name="Resimx" type="file" />
        <input type="submit" value="Upload" />
    <% End Using %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I didn't find any tip about DirectX installation at Inno-Setup web site. So, is
I didn't find an answer on the net and i hope this question have
Didn't find any from their website. I mostly just trying to see which one
I didn't find any solution that helped me on the older questions on SO...
I didn't find an answer to this question because I don't know if I'm
I didn't find any documentation on how to create an aggregation with Layout Style
I didn't find any info on searches when I looked this up. I've been
I didn't think I made any tweaks to my machine configuration lately but all
i didn't tested this code on iPhone but i'm sure (tested) it doesn't works
I didn't change any setting of my Vim, but today the Backspace gets some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.