Need to understand why upload isn't happening in this case? - asp.net-2.0

I've an html file with the below markup:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Upload Page</title>
</head>
<body>
<form id="frmUpload" action="UploadHandler.ashx" method="post" enctype="multipart/form-data">
<input type="file" /><br />
<br />
<input id="Submit1" type="submit" value="Submit" />
</form>
</body>
</html>
I have a handler (ashx) file to handle the upload which goes like this:
<%# WebHandler Language="VB" Class="UploadHandler" %>
Imports System
Imports System.Web
Imports System.Diagnostics
Public Class UploadHandler : Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim str As String
str = "EncType = " & context.Request.ContentType
str &= vbCrLf
str &= "File Count = " & context.Request.Files.Count
context.Response.ContentType = "text/plain"
context.Response.Write(str)
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
When I am working with the html page, I select a file and do a submit, I get a response like this:
EncType = multipart/form-data; boundary=---------------------------7d9232a130656
File Count = 0
I was expecting the file count to be 1 here but it is 0...what is wrong?

Try giving a name to your input tag:
<input type="file" name="fileToUpload" />

You don't have a name attribute on your file <input>:
<input type="file" name="myFile"/><br />

Related

Image not displaying on webpage just shows source

I am trying to dynamically display an image with text on it. There are quite a few examples of this ie Write Text On An Image in c#
For the time being this is the only thing on a visual studio generated empty winform page.
but I continue to get the same result regardless of the technique is use, so perhaps its a problem with my page?
My output page displays like this:
<%# Page Language="vb" AutoEventWireup="false" CodeBehind="index.aspx.vb" Inherits="testtext.index" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
</title></head>
<body>
<form method="post" action="./index.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="G30FF0+ZAHGhkQJeBgR+oRS6OrykggI6KG2KLa2Mf0lna5zKb83yvLWtkQfnBa4AEDqKkttFuBoZ1lWeDcgqUpLSg0hHsyoD0paxcB2U0Js=" />
</div>
<div>
<p><img src="data:image/PNG;Base64, �PNG���
IHDR���5������9堢���sRGB�������gAMA����
�a��� pHYs�������o�d����IDATHKՓ��0�;�9Nvq�lb����D� />
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="90059987" />
</div></form>
</body>
</html>
My code looks like this:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtmstrong textl">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%Dim cls = New testtext.clsUtil %>
<p><img src="data:image/PNG;Base64, <%cls.MakeImage("Testing") %>" />
</div>
</form>
</body>
</html>
the function .MakeImage ends as follows:
'// SET ALIGNMENT
Dim format As StringFormat = New StringFormat
format.LineAlignment = StringAlignment.Center
'// DRAW THE FONT
Dim oMemStream As MemoryStream = New MemoryStream
g.DrawString(Text, oFont, fgBrush, rectF, format)
System.Web.HttpContext.Current.Response.ContentType = "image/png"
img.Save(oMemStream, ImageFormat.Png)
oMemStream.WriteTo(System.Web.HttpContext.Current.Response.OutputStream)
'// CLEAN UP
img.Dispose()
Return Nothing
End Function
The function .MakeImage appears to be working correctly returning the image but sadly no picture is displayed.
Can you see what I am doing wrong?
two things:
your output is not base64 encoded, and your page output you’ve listed doesn’t have a closing double-quote on src=“...
Let me know if you need code on how to resolve. Deal with base64 first, in case the current output is messing up the page output.
Cheers!
Added:
use Convert.ToBase64String(bytes) to encode your bytes into a Base64 string.
Or, if you want to continue to return bytes to the client, consider just putting an image URL in like src=“/images.ashx/testing", then setting up an ASHX handler to call your image-generating function. You can return bytes without encoding.

aspx Request.Form.Count=0

I am not getting any data when submitting a form. I would expect Request.Form.Count=2, but instead RequestForm.Count=0.
Any assistance would be appreciated.
<%# Page Language="VB" EnableViewState="false" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="ecomm_Default2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<form id="form1" method="post">
<input id="textfield" type="text" value="My Text" />
<input type="submit" value="Send it" />
</form>
</body>
</html>
Code behind part
Imports System.Diagnostics
Partial Class ecomm_Default2
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Request.HttpMethod = "POST" Then
Debug.WriteLine(Request.Form.Count)
End If
End Sub
End Class
You input fields are missing names. Make sure you add them:
<input id="textfield" name="foo" type="text" value="My Text" />
<input type="submit" name="bar" value="Send it" />
Now on the server you will get both foo and bar keys with their respective values.

Set or get html tags value or innerhtml in razor view

how to set or get html elements inner text or html controls value in Razor syntax.
i know how we can do this in aspx file using Runat="server" attribute like this
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title><%Response.Write(Page.Title); %></title>
<script runat="server">
protected void Button1_ServerClick(object sender, EventArgs e)
{
p1.InnerText = "Hello " + textbox1.Value; //get textbox value and set in html p tag
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="text" id="textbox1" runat="server" /><br />
<input type="button" id="btn" runat="server" value="Click Me" onserverclick="Button1_ServerClick" />
<p id="p1" runat="server">see result here</p>
</div>
</form>
</body>
</html>
Basically something like this...
View (SomeAction.cshtml):
...
<p>ViewBag.SomeValue</p>
...
Controller:
...
[HttpGet]
public ActionResult SomeAction()
{
ViewBag.SomeValue = "Hello";
return View();
}
...
However you should learn much about approach which is used to build applications using ASP.MVC. It's completely different than ASP.NET WebForms. WebForms technology uses events while ASP.MVC uses Model View Controller. You have to change your mindset.

Add attachment to email

Can anyone sort out the following code to make the adding an attachment to an email work please.
Thanks
<%# Page Language="VB" ContentType="text/html" ResponseEncoding="ISO-8859-1" Debug="true" %>
<% #Import Namespace="System.Web.Mail" %>
<% #Import Namespace="IO" %>
<script language="vb" runat="server">
Sub btnSendEmail_Click(sender as Object, e as EventArgs)
Dim objMM as New MailMessage()
objMM.To = "my#email.co.uk"
objMM.From = "their#email.co.uk"
objMM.BodyFormat = MailFormat.HTML
objMM.Priority = MailPriority.Normal
objMM.Subject = "Attachment test"
objMM.Body = "There should be an attachment with this email"
objMM.Attachments.Add(new MailAttachment("myimage.jpg"))
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(objMM)
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:Button runat="server" id="btnSendEmail" Text="Send email" OnClick="btnSendEmail_Click" />
</form>
</body>
</html>
I'm suspicious about
new MailAttachment("myimage.jpg")
I suspect you might want to get the full path e.g.
new MailAttachment(Server.MapPath("Myimage.jpg"))
The file path needs to be a full path but that aside, System.Web.Mail is deprecated/obsolete. You should be using the System.Net.Mail API, see here for examples.

Downloading a text file in ASP.NET is appending the web page HTML

Thanks to help I previously received on this forum I was able to get my asp.net web site to download all kinds of files to the client browser.
For some odd reason, when I download text files, the HTML of the web page is being appended to the text! All other file types work fine!
Here's the code that's doing the download:
Public Sub DownloadBlob(ByVal Blob As Byte(), ByVal FileName As String, ByVal Response As HttpResponse)
Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", FileName.Replace(" ", "_")))
Response.ContentType = String.Format("application/{0}", Path.GetExtension(FileName).Substring(1))
Response.BinaryWrite(Blob)
End Sub
and here's what's coming out of my text file:
Here is a test file
I hope it works!
:)
Saul
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
EEI - Case
</title><link rel="stylesheet" href="EEI.css" />
<script language="javascript" id="jssembleWare" src="sembleWare.js"></script>
</head>
<body>
<form name="form1" method="post" action="EEICaseEditForm.aspx" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENT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AAAAAAoGbgEAAAlNeVNpZy5KUEcICAcAAAAQwwAAAAQAAAAICQ8AAAAAAAAACgluAQAACAgHAAAAEMQAAAAGAAAACAIGCAIBCAIFCAIFCAICCAICEMsAAAAKAAAACAkHAAAAAAAAAAoGbwEAAAg0MjNQUjkDEwoICAUAAAAICAEAAAAKCAgIAAAADQIQzAAAAAoAAAAICQcAAAAAAAAACglvAQAACggIBQAAAAgIAQAAAAoICAgAAAANAhDNAAAADgAAAAgCBggCBwgCBQgCBQgCBQgCBQgCBQgC
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<!--Script to confirm btnEditDocument Action-->
I didn't include everything; you get the idea.
So, what is wrong with my code, and how do I prevent this from happening?
You need to call Response.End.
Public Sub DownloadBlob(ByVal Blob As Byte(), ByVal FileName As String, ByVal Response As HttpResponse)
Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", FileName.Replace(" ", "_")))
Response.ContentType = "text/plain"
Response.BinaryWrite(Blob)
Response.End()
End Sub
Also notice I set the ContentType a little differently.

Resources