"Validation of viewstate MAC failed" on postback to a different page - asp.net-3.5

I'm working on a web form which works fine as long as it posts back to itself. In Reports.aspx I have:
<form runat="server" method="post">
but, when I try to get it to post to a different page:
<form runat="server" method="post" action="DisplayReport.aspx">
I get the "Validation of viewstate MAX failed" error. I've tried setting the machine key and disabling the viewstate in web.config, but nothing seems to help. Am I stuck posting back to the same page? If so what is the point of the action attribute?

You can submit to a different page, but you need to use the PostBackUrl property of a button, not the form's action attribute.
Instead of this:
<form runat="server" method="post" action="DisplayReport.aspx">
<!-- form stuff goes here -->
<asp:button runat="server" text="Submit" />
</form>
Do this:
<form runat="server">
<!-- form stuff goes here -->
<asp:button runat="server" text="Submit" postbackurl="DisplayReport.aspx" />
</form>

Cross page post backs should be available, you just have to set them up as so. See this link http://csharpdotnetfreak.blogspot.com/2009/08/cross-page-posting-in-aspnet.html

Related

Submit basic HTML form using Postman

I am trying to log into this website using Postman.
There is no username and this is what the HTML look like:
<body>
<div class="container">
<div class="loginbox">
<img id="logo" src="../gfx/logo.png" alt="" />
<form action="" method="POST">
Password: <input type="password" name="password" id="password" />
<button type="submit" name="submit" id="submit">Submit</button>
</form>
<p id="message">
</p>
</div>
</div>
</body>
This my POST request on Postman and I am not getting any "Wrong password." html back so I guess I am not doing the correct thing. How can I make a POST request to login using Postman?
The form includes two values, password and submit. The latter has no value associated with it, but the key is still being posted to the server.
It seems that the server-side code is using the submit key to trigger its logic. Just include that in your form data with no value.
Giving a "submit" key as empty in addition to the password field is needed . Please refer the sample request image given.

Netlify does not recognize form in nuxt app

We implemented a simple nuxt app with a basic form and deployed it to netlify.
When pressing the "Submit" Button of the Form, we receive a 404.
Here you can find the link to the deployed netlify app:
EDIT -> Removed Link
After looking through the troubleshoot guide, they listed that the added "netlify" or "data-netlify="true" attributes should not be visible if netlify recognized your form, but they are.
Plus the form can't be found in the "form" configuration tab of the netlify backend.
Nuxt config:
SPA
Tailwind
We tried to add the necessary attributes for netlify:
netlify or
data-netlify="true" & netlify-honeypot="bot-field"
We also added a "pre-render" library called prerender-spa-plugin.
Here you can find the contact.vue page content.
Simple form with "name" attributes set according to netlify documentation.
<template>
<div>
<form name="contact" method="POST" data-netlify="true" netlify-honeypot="bot-field">
<p class="hidden">
<label
>Don’t fill this out if you're human: <input name="bot-field"
/></label>
</p>
<p>
<label
>Name
<input
type="text"
name="name"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white;"
/></label>
</p>
<p>
<label
>Email
<input
type="email"
name="email"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white;"
/></label>
</p>
<p>
<button
type="submit"
name="submit"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
>
Send
</button>
</p>
</form>
</div>
</template>
<script>
export default {};
</script>
<style>
.hidden {
display: none;
}
</style>
It would be great if we can manage to fix this, so that netlify finally recognizes our form.
Netlify comes with built-in form handling. Our build bots do it by parsing your HTML files directly at deploy time, so there’s no need for you to make an API call or include extra JavaScript on your site.
The form is required to be in the rendered files at deploy time. The problem with SPA mode is that none of your pages are actually rendered as HTML. You can check this by right clicking the page, and clicking "View Page Source". You won't be able to find the form.
Netlify addresses this problem here in their docs.
They have a specific post for fixing this for a Vue app here
A little more digging on the the issue and we find a Nuxt solution here:
Place the following in static/form-dummy/index.html:
<form name="MYFORM" action="/form/success" netlify>
<!-- form controls here -->
</form>
Place the following in pages/form/index.vue (Or whenever you've named your Vue file)
<form name="MYFORM" action="/form/success" method="post">
<input type="hidden" name="form-name" value="MYFORM" />
<!-- form controls here -->
</form>
From the post:
You just need to make sure you add that hidden in the Vue component so that Netlify recognises the form submission as associated with the form called MYFORM. I think you also need to ensure all the inputs you want to receive data for are on both forms.

post form to an iframe on another form (is it possible)

I'm using ASP.NET web forms and i need to post data to an iframe, the problem is that in web forms I have the main form tag(form1), so i need another form tag(form2), to post data to the iframe that is in the main form1.
Basically i have this:
<form method="post" id="form2" action="http://localhost:58903/WebForm1.aspx" target="webApp">
<input type="hidden" name="ValidationUserName" value="david" />
<input type="hidden" name="ValidationTokenId" value="13123132132" />
<button type="submit">Send info to inner iframe</button>
</form>
<form id="form1" runat="server">
<iframe id="webApp" name="webApp" src="http://localhost:58903/WebForm1.aspx" style="width: 800px; height: 800px;"></iframe>
</form>
With this approach in open a new tab, if i put the iframe outside it works ok, but if i do this the layout is changed and i don't want this.
Is this possible?
If all the forms are in the same domain you should not work with iframes.
What exactly are you trying to get here? didn't realize completely
Done it, it was missing the "name" attribute in the <form> tags.

Tumblr: Search returning no search results

I'm new to tumblr and am trying to implement Search in a custom theme. I have:
<form action="/search" method="get" id="search-form">
<input type="text" name="q" class="query" value="" />
<input type="submit" value="Search" class="submit" />
<div class="clear"></div>
</form>
I have about a dozen posts. Whenever I search for anything in any post, Tumblr always returns no search results. I feel like I'm missing something. Am I to implement or set any configuration anywhere else in the theme? What else is needed to implement search in a user's Tumblr theme?
Thanks!
Here's the solution I use. Put this into the <head> of your code:
<script type="text/javascript">
<!--
function handleThis(formElm)
{
window.location="/tagged/"+formElm.number.value+"";
return false;
}
-->
</script>
And place this where you want the search box to appear:
<form onsubmit="return handleThis(this)">
<div class="submit"><input type="submit" value="{lang:Search}" name="Submit"/></div>
<div class="input"><input onfocus="this.value=''" onblur="if(this.value=='') this.value='Search. Then hit enter.';" type="text" value="{lang:Search}. Then hit enter." name="number"/></div>
</form>
Use CSS to style as you wish. This will search your tags only, but unlike the regular Tumblr search it works.
I was getting no results when my blog was password protected. I removed the password protection from Tumblr Dashboard > settings > blog name > password and it started returning results again.

Safari 3.2.1 sends POST followed by GET requests

I've a servlet running on Tomcat 5.5.27 and 5.5.26 and have a web form with POST method.
If I use Safari 3.2.1 I see from the logs that Tomcat receives a POST followed immediately/contemporarily by GET and it fails.
If I use Firefox 3.0.5 I see that it sends only POST and everything works.
Trying to debug with Eclipse I see that when using Safari it is the doGet() method that is called while when using Firefox is doPost().
Practically it seems that Safari fires both POST and then immediately GET, while Firefox fires only POST (as it should according to the HTML form).
Is there somebody else who as experienced this ? In this case is there a solution ?
Here is a snippet of the HTML form:
<form action="/vidisearch/Search" method="post" name="SearchForm" id="SearchForm">
<div class="input required">
<label for="Concepts">Concepts, comma separated<br />
ex. (remove quotes) "man-made object, cemetery, graphic event, atmospheric event, tool event"</label>
<input name="concepts" type="text" value="" id="concepts" />
</div>
<div class="input required">
<label for="Operators">Operators, comma separated<br />
ex. (remove quotes) "NOT, AND, OR, AND, AND"</label>
<input type="text" name="operators" value="" id="operators" />
</div>
<div class="input required">
<label for="Specializations">Specializations, comma separated<br />
ex. (remove quotes) "true, false, false, true, false"</label>
<input type="text" name="specializations" value="" id="specializations" />
</div>
<div class="input required">
<label for="Results">Various parameters</label>
<table width="100%" border="0" style="border: 0;">
<tr>
<td>Ontology ID<br />
<input name="ontologyID" type="text" id="ontologyID" value="" /></td>
<td>Result page<br />
<input name="page" type="text" id="page" value="0" /></td>
<td>Shots per page<br />
<input name="shotsPerPage" type="text" id="shotsPerPage" value="20" /></td>
<td>New search<br />
<input name="newSearch" type="text" id="newSearch" value="true" /></td></tr>
</table>
</div>
<div class="submit"><input type="submit" value="Search" /></div>
</form>
I think you have an image tag that has an empty src.
It's hard to say without seeing your HTML for the form, but perhaps your submit button is a wrapped with a link, and Safari is both POSTing the form and following the link (via GET).
I'm not sure what's happening but what I do know is that you need to provide more information.
Maybe it's sending a GET for associated resources (like images) whereas Firefox keeps them in the cache, or you have the form submit button inside an <a> tag, for instance.
Another alternative is a Javascript incompatibility, in case you are submitting something via Javascript.
Sniff the traffic (check out Fiddler or Wireshark) and see what is Safari trying to GET and what's it is POSTing
I'm quite puzzled by the behaviour of Safari since I remind that sometime ago it worked. I'm fearing that one of the latest upgrades has broken something.
Using HTTPScoop I've seen that apparently Safari fires POST followed by GET when it gets the response. I think however that it actually fires both requests at the same time since the date+time of the two responses is the same for both POST and GET.
The response is a RSS feed and has the HTTP/1.1 200 OK code. The second GET asks for the same request URL (http://127.0.0.1:8180/vidisearch/Search) of the POST but the body is 0 bytes, it has of course no GET parameters and the answer is wrong because of the missing parameters.
Firefox instead fires only the POST and gets the correct answer.