AjaxControlToolkit's AsyncFileUpload misbehaving when deployed online - c#

In case it matters, the following is inside a toolkit popup, which has an update panel in it.
<p>
<asp:Label Text="Picture" runat="server" Width="75"></asp:Label>
<ajaxToolkit:AsyncFileUpload ID="MediaPicture" runat="server" Width="200"
OnClientUploadStarted="BlockSubmits" ClientIDMode="AutoID"
OnClientUploadError="UnblockSubmits" PersistFile="true"
OnClientUploadComplete="UnblockSubmits"
/>
</p>
The javascript functions just block / release a submit button, to prevent problems during uploads.
This works fine on localhost, but when deployed online on a GoDaddy server, I can't seem to upload files over a few KB, even when locally I could upload bigger files (~2MB)...
I can't seem to find the reason for this behavior, could it be on the IIS? I read something about the app pool clearing before the upload could complete, could this be happening?
Btw, just in case, server-side I just take the picture out of this control
byte[] picture = MediaPicture.FileBytes ?? (string.IsNullOrEmpty(mediaID) ? null : Media.SelectByID(int.Parse(mediaID)).GetPicture());
There's some extra logic in there about whether I'm in edit mode or not, and if the current record has a picture, I'll take that over no picture,
And then I store it on the database.
any thoughts as to why this might be happening?
thanks!

If I understand your situation correctly, the problem is caused by the AsyncFileUpload being located inside the updatepanel, thereby having the file upload happen during a postback...
This blog post has a decent explanation of why.
As for why it works locally, if it is the problem as explained above, it's because of the way the browser handles "local" from "internet" domains.

The Assync upload of the ajax toolkit still has to have a post with the maximum request size of ASP.NET.
This max size is setted in the web.config of your application AND inside IIS. Since you are using a third party provider... try to fiddle with the web.config in the section
<httpRuntime maxRequestLength="40960"/>
If this won't help you out, check out the SWFUpload control... saved my skin a couple of times.
Regards,

I guess you use different IIS versions in your development environment and in the the production server (in this case Go Daddy).Can you verify and let me know the exact IIS versions so that I can provide you a better solution? Cause IIS 7.0 has a slightly different configuration than IIS 6.0.

I was experiencing the exact same problem, but including the website in the "Local Intranet" zone in IE the security setting was a workaround.
However, I updated the Ajax Control Toolkit and the problem was completely solved. There is no more need to mess with the security setting.

Related

Localhost Redirected you too many times DotNetNuke

I have a DotNetNuke application I am trying to setup on localhost.
The application was working fine until I tried to change database connection. After reverting back the changes I made in conenctionStrings, I am getting error whenever I try to run it. The error is
The localhost page isn’t working
localhost redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS
Well, obiously I tried clearing cookies and also tried on multiple browsers but getting same result. Page is not working.
What can be the possible reason ?
Without seeing any source code the best answer I can give you is this, something in your code if forcing a redirect to iteself, which then forces another redirect to itself, etc.
It would basically by the same as doing this,
void DoSomething() {
// Infinite loop, activate!
DoSomething();
}
If you provide some source code or a link to it in the question I could give you a more detailed solution, but as the question stands this is the best I can do.
I had this issue a while ago, setting the trust level to full trust (in web.config) solved it for me.
Happy DNNing!
Michael

Asp Image Button Image Not Changing

Recently I came across a problem with an Image Button in an ASP.Net application.
The image file was replaced with the same name in the server when user uploads a new Image,but The image button still showed the old Image even after the page was refreshed.
Did Overcome this issue by adding a query string to the ImageButtom url
Image1.ImageUrl="images/ID102.jpg?"+DateTime.Now.ToString("ddmmyy");
Would like to know if this is the only solution to this??
You should include hours, minutes and seconds to resolve caching problem (also you can add random number but not current datetime))
Your browser was likely caching the old image since it had the same url.
Refresh the page with ctrl+f5 or open up your developer tools and turn off caching in the options.
You can also detect caching by hitting F12 in your browser and looking at the network tab and watching the requests. If you see a "304 Not Modified" it means it's using a cached version.
I always use Google Chrome's Incognito mode to discard any stored cookies/cache while testing my apps.

Site using code behind files from the wrong directory?

What settings in ASP.NET determine where (as in which directorie(s)) a website will look for its code-behind files?
I have two versions of an asp.net c# website, Live and Dev.
Live site: www.example.com with the pages and code in c:\dev\websites\examplecom_new
Dev site: d3.example.com with the pages and code in c:\dev\websites\examplecom-d2
There are historic reasons why the live site's directory ends in _new and why the dev site has d3 as its hostname and -d2 on its directory name, but they work and until now we've had no issues, developing things on d3 for subsequent release to live.
I recently refreshed the dev site to be an exact copy of the live one (I usually do this before starting a new round of work), and started on some development work. However, when I tried to run the code via the website, even though the browser was showing the Dev URL, d3.example.com, the error message referenced a code file from the live site's web directory, c:\dev\examplecom_new, not the development version c:\dev\examplecom-d2.
I've gone through the code in detail to ensure there are no hard-coded references to either the www site or the path to the live site directory, and as far as I can tell there are none. The code files in all cases are referred to in the .aspx files as local links, for example:
<%# Page Language="C#" MasterPageFile="~/ExampleCom.master" AutoEventWireup="true"
CodeFile="Checkout.aspx.cs" Inherits="Checkout" Title="Untitled Page" %>
Yeah, I know "Untitled Page" isn't the most useful title in the world. :)
I've gone through web.config, had a look in app_code\general.cs, and checked all the tabs on the Properties element in IIS, but I can't find anything that could be telling the site to use the .cs files from the live dir instead of the dev one.
I tried restoring the previous (pre-refresh) version of the Dev site (I always back them up before replacing, just in case), just in case there was a config change I wasn't aware of, but the old version exhibits exactly the same problem, the Checkout page calls code from live, not dev, even though its URL is showing the dev verson in the browser.
Needless to say this is something of a showstopper, the error that's happening appears to be due to a session mis-match between live and dev, but I have no idea why the dev site is calling code from the live site instead of code in its own directory. Any pointers to what might be wrong would be appreciated. I've tried both Googling for "asp.net code behind files called from wrong directory" and related searches, and searching Stack Overflow for the same types of thing, but not seen anything related. We're not using pre-compiled binaries, just standard .aspx pages and .aspx.cs C# code files.
At first I'd assumed there must have been a hardcoded redirect kicking things over from dev to live, however I can see no trace of one and the browser address bar still shows d3.example.com/Checkout.aspx when I'd have expected a redirect to live to change it to the www version.
The webserver is IIS 6 and we're running ASP 2.
Run "iisreset" command from command line and then clear temporary folder. All applications will be recompiled after that.

POSTing to a re-written URL on IIS 6 doesn't work

I am working on a site which is programmed in C# .net. It uses a CMS called ADX Studio (a decision which predates my time there) which provides a shonky form of URL Rewriting (as far as I can tell it works by assigning an aspx page as the default 404 handler in IIS).
I have an web form which lives at a rewritten URL. I edited it so that the html form's action points back to the rewritten URL:
var u = new Uri(Request.RawUrl.Split(new char[1] { ';' }).Last());
userAdminForm.Action = u.PathAndQuery;
(kind of ugly but works based on what Request.RawUrl is on these rewritten URLs).
The "pretty" URL is something like this:
http://www.site.com/admin/user/edit/
On my development box (Windows XP/ IIS 5) when I initially tried POSTing back to URLs like this I got a HTTP 405 error. I worked around this by adding a script mapping so Aspnet_isapi.dll handles all (*) requests. And everything works fine on my development machine.
I just pushed my changes to the live server (Windows Server 2003 R2 and IIS 6) and the post fails silently. The page refreshes but all of my logic (from within an IsPostBack path in the code) doesn't get hit. No errors are displayed, it just doesn't work.
If I remove my code setting the .Action of the form then the postback works but it is posting to the ugly URL corresponding to the physical location of the aspx file rather than my page.
Am I missing a simple way to make this work? I don't want to be switching URL rewriting method or anything as this is a large legacy site and is unfortunately pretty dependent on ADX Studio so I don't want to do anything that will break that.
[edited because somehow the code above lost its code highlighting]
The issue is that the page's <form> tag is referencing the "ugly" url as the action. You can resolve that by completely removing the action tag from the form. Browsers will, by default, postback to the same page, ie. the "pretty" url.
This article explains how to accomplish an "actionless" form (~ two thirds of the way down) http://msdn.microsoft.com/en-us/library/ms972974.aspx
It seems like the problem is the same as it was on IIS 5. I can get it to work by doing the following in the IIS Manager:
Right click on the relevant website and select "Properties"
Choose the "Home Directory" tab
Click "Configuration" down in the "Application settings"
Click "Insert" next to the "Wildcard application maps"
Browse to the location of aspnet_isapi.dll (in my case: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll )
Untick "Check that file exists"
Click "OK" back through the Russian doll of dialogs.
This is basically the same as the approach that I linked to in the question for IIS5. However, it's not optimal because IIS is running every request through asp (even static files). Which seems like it can only slow things down. I'd like to be able to specify that asp only needs invoking for HTTP POST requests at least.
The weird thing is that IIS5 gave a HTTP 405 error when POSTing to an extension without a registered ISAPI extension but IIS6 just fails silently. And the page is being run through IIS (I can debug with a breakpoint in the Page_Load function) but IsPostBack (and IsCrossPagePostBack) don't get correctly set. Could it be related to the view state? Is there any alternative to my solution described above?
I've come to what I think is an optimal solution for this problem. It turns out that ADXStudio CMS does use the default 404 rule to do some form of URL rewriting. This has a problem with http POST:
when IIS initially executes a custom
URL on a 404 error, it changes POST to
GET, even if the client does a POST
request.
(thanks to elite brains' blog post about setting up IIS6 and ASP.NET MVC).
Rather than creating my own HttpModule I decided instead to use Ionics Isapi Rewrite Filter to rewrite my URLs. I then set the 404 error handler in IIS to the default. And I created this IIRF.ini file to redirect all requests to the same format as the 404 handler produced:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /Default.aspx?404;http://%{HTTP_HOST}$1 [U,L]
And everything seems to work great. The advantage over my previous answer is that the rewrite code is low level and runs fast and the -f and -d switches mean that if a file actually exists it isn't re-written and so static files don't have the overhead of running through .net.

MVC site using relative paths for links instead of view syntax

EDIT!! I should add that this site runs perfectly locally. It's only when deployed that there's this issue
ORIGINAL POST:
I have a site I just put up http://splattonet0.web704.discountasp.net/
Which loads the Index view of the Home controller just fine. However, when one clicks the links to the left, the webserver is looking for the relative paths (ie E:\web\splattonet0\htdocs\Home\AboutMe) which is incorrect, since Home folder is of course under a folder called "Views"
I've made MVC sites before and have never had this problem. I can't see any difference between this or any other site I've done.
My code in my master template for the link section is as follows:
<div id="navContainer">
<ul id="mainNav">
<li>Home</li>
<li>About Me</li>
<li>Skills</li>
<li>Resume</li>
<li>Experience</li>
<li>My Websites</li>
<li>References</li>
<li>Projects</li>
<li>Hobbies</li>
....etc
</ul>
</div>
I have the same problem with and without the preceeding foreslash in the href property. I've decided to keep it there since that is how my other sites (that work!) are styled.
Can anyone shed some light on this for me? Thanks!
FURTHER EDIT:
I have been asked to provide code from an MVC site on this server I have written and that works fine. The link code in the other site (YorkCentre) is the same style: <li>text</li>
The code:
<li>Archived News</li>
<li>Board Of Directors</li>
<li>In The Media
...
</ul>
/Home/Index should be calling the "Index" action of the "Home" controller, assuming you're using default routes. The fact that "Home" is under the "Views" folder is irrelevant for MVC.
If the code is the same in both locations, and the issue only happens in one, perhaps the answer lies not within the code. The following are some troubleshooting tips which may help, as I don't know exactly what the issue is without more information about the two environments.
What are the web server platforms for your local environment and the server environment? Are you using Visual Studio and Cassini locally, and IIS remotely? If so, which version of IIS? If not, what is the platform? In any event, is the target server configured correctly?
Check to make sure your routes are set up correctly on the target server. This is especially true if your target server runs IIS6 -- IIRC, IIS 6 needs some special configuration help to deal with the standard routing in ASP.NET MVC.
If all of the above don't help you trace this out, try to replicate it locally by creating a new MVC site and merely dropping your existing files into it. See if that succeeds or fails.
Do you have other successfully-executing ASP.NET MVC apps on that server? Check their configurations against your new site's.
I have resolved the problem! In DiscountASP I have changed the Application Pool Pipeline Mode from Classic to Integrated and that results in my views being properly rendered.

Categories

Resources