I have a web app using validation control such requiredvalidator. When I run it from VS 2008 directly, it worked perfectly (validated the missing input). But the moment I published it to IIS, it does not validate it anymore..
any ideas?
thanks
Use firebug or IE8 built in web developer toolbar to see if the scripts get downloaded for the validation to run. Also check if the generated client id equals the one that is used to set up the validation (javascript at the bottom of the generated html).
Apparently this is a common problem with asp.net. found the solution from here: http://www.velocityreviews.com/forums/t92775-asp-net-client-validation-not-working.html
Related
Let's be clear, I don't really like WebForms. Which is why I do not wish to spend hours debugging a legacy code base that ran perfectly well on one server (IIS7) and a new one (IIS8).
I heard there is this new ClientIDMode, which makes forms and other controls change their IDs or not to something sensible, but I didn't touch it. It seems like the default value has changed (ie is not backwards compatible)?
I had a form in a master page that looked like <form id=SiteForm runat=server
This automatically changed its ID to aspnetForm in the rendered output.
Sure it was a bit weird, but I have a lot of code in this app that relies on it. I could simply change the ID in the server page to <form id=SiteForm runat=aspnetForm and that might fix it. But maybe there's some code in this old project that uses SiteForm on the server side, so I can search for that.
But there could be other controls lurking around which had their IDs changed too. So maybe there is something I can add to the web config to turn the behaviour back to what it was before? What was the default before?
UPDATE: Looks like when exporting and importing the app pools this site somehow got changed from .NET2 to .NET4, so perhaps I just need to set it back to .NET2?
I found that I had not ticked the box to install .NET 3.5 within IIS setup. This is why all my app pools reverted to .NET 4 automatically and why these weird changes happened. So I installed it in IIS, restarted, and set the app pool to .NET 2 (ie 3.5). This fixed it, cleanly, so I will call that the solution.
I have a MVC5 project using signalr to perform updates to a list. Inside script.js, there is a variable link to defined as var link = $.connection.hub. There is also a bundleconfig file to load the dependent scripts, signalr/jquery and jquery in the proper order of course.
The script /signalr/hubs is loaded in from the html manually.
bundles.Add(new ScriptBundle("~/bundles/signalr").Include(
"~/Scripts/script.js",
"~/Scripts/jquery.signalR-2.0.2.min.js"));
When the VS 2013 Web project is run, it works fine until the project is copied over to another PC that it does not work as intended. The variable link is undefined as $.connection is undefined too ($ is defined though).
I presume that jquery.signalR-2.0.2.min.js is not read or executed at all.
Questions:
Might this have anything to do with the environment of the PCs? (Windows 7 is OK, Windows 8 is not OK)
What could prevent jquery.signalR-2.0.2.min.js from running?
Does creating a new View/Controller play a part in the error (creating a view, using a layout page)?
Please see similar question: SignalR and MVC bundle as it shows how to add SignalR into an MVC bundle. I think their answer should help solve your problem.
I would comment instead of answer, but I don't have enough reputation.
I am trying to display some text using MessageBox.Show as shown below in a page_load event in ASP.NET. Before anyone jumps on the case why I am using it in ASP.NET, the use is for debugging only on my own dev box for a special need. There's a reference to System.Windows.Forms in the app.
I used it a few years ago so I know WinForm's MessageBox works. I am using .NET 4.0 and VS 2010. I don't think anything related to this function has changed.
MessageBox.Show("Message", "Caption", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); //used also ServiceNotification option
Any ideas why the message box doesn't display? I have only that line in the code.
ADDITION:
I am VERY AWARE of the message box thing implications. It's a temporary thing for debugging only. The line won't go into production. I have no access to javascript. Please put your thought into why it doesn't work instead of why I shouldn't be using it. I have used it before in 2.0 and it does work. I want to know if the newer .NET changed anything or I misused the option.
Direct Answer: it works in Visual Studio's web server , not in IIS.
The web application is hosted in a process that does not have a desktop, so you cant see any messageboxes.
#Tony, if you add System.Winform.dll to your rference, then you will be able to call message box.show at you development machine. But when you deploy it to some live server it will not work. So alternatively, you need to use javascript alerts. For this you can use this
private void ShowMessage(string message)
{
ScriptManager.RegisterClientScriptBlock(control, GetType(),"key","string.format("alert('{0}');",message),true);
}
Back in .Net 2.0 days, you could do this by including system.windows (I think) in your using statement.
Then, in the method, it would be system.windows.forms.Messagebox.show("foo");
I won't presume to tell you "yer doin it wrong"...
Just be aware that this will only show up on the server box, and could cause issues in a production environment.
The alert() is better, and console.log() is even better.
ASP.NET 4.0
I've checked that using both or control (which is a wrap of html file input) will display "C:\fakepath\MyFile" in both Google Chrome 12.0 and IE8.0 on my Windows 7. It only displays "MyFile" in FF3.6. I am trying to not display "C:\fakepath\" string since it's not usual to most users.
I already enabled displaying full path in IE security setting which mentioned in another SO thread, so that shouldn't be just an IE security issue. Not to mention GC is showing fakepath too.
I am more suspecting it's because of my compilation environment -- Windows 7 + VS2010 SP1 + MVC3 installed. Can the community tell me how to disable this?
It can't be disabled, it's a browser security feature. It ensures the server doesn't have access to any file information on the client. Some browsers handle it differently, which is why in FF you just see the file name.
See this related question:
Javascript loading clients local media
Hi I have created a user control which is inside a folder called Controls and the class is a partial class which inherits from Web.UI.UserControl. Now from my page which is one level up I just try to access the method inside the usercontrol and so trying to cast it as the type of user control.
But I get build errors. It just cannot recognize that class. I get Type not defined error. But at times it has recognized the class. Dont know why it does that.
Hi Finally I was able to resolve the issue by converting to web application from a website. Now it works exactly as desired. I think there are problems with visual studio website apps. As far as I have read websites do not have as robust support as web app has. So thankyou all for your comments. Finally the flakiness is gone.