ASP.net MVC 3 Alert messages cause error message on page. (Unable to display alerts)

I have a page that first checks to see if the message property contains a value, if it does then display it.  The problem is that when I publish the site to the web server, the page displays an error; see attached.  If I comment out the alert(msg) the page displays without an error.  If I uncomment, it errors out.  Not knowing enough about this I'm not sure what to consider as the problem.  i suspect it's iis related or permissions, but not sure.

<script type="text/javascript">
    $(document).ready(function () {

        var msg = '@ViewData["Message"]';
            if (msg != "")
            alert(msg);  //problem line
    });

</script>
EE-Alert-Err.bmp
Steve7423Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Patrick BogersDatacenter platform engineer LindowsCommented:
Hi

This can mean many things.

What applicationpool(user) is running the app?
Does the webserver uses the same framework like .NET4,5 as on your developing machine?
Can you try using <customErrors mode="Off"/> between the <system.web> tags?

Do you see an error in the logfiles for this website?

It is a lot but most of the time not to difficult.
0
Steve7423Author Commented:
1 applicationpool, I might need a hand with this, not sure what you're speaking of.
2 yes I installed frameworks 4 and MVC 3
3 it was set to remote only, I changed it to off, published again, opened the site but it still displays the error.
4 not sure where to look for the log files, ..some direction ?
0
käµfm³d 👽Commented:
What does this line:

var msg = '@ViewData["Message"]';

Open in new window


...look like in the client-side source code?
0
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Patrick BogersDatacenter platform engineer LindowsCommented:
Ok app pool is important.
In IIS select your website and click 'basic settings' on the right.
This will display your application pool, now in IIS (left on top) go to application pools and select properties for the app-pool you just found.
I expect to find a .NET 2.0 default apppool which doesnt work if your app is build on .NET4

(i am assuming you use IIS 7 or higher)
0
Steve7423Author Commented:
kaufmed: here's the line from the controller which populates the message of viewbag

if (Convert.ToInt32(DAL.Get_CurrentUsersProjectNo()) > 0)
            {
                ViewData["Message"] = "";
            }
            else
            {
                //err name
                string err_Name = "missing_project_number";
                Errors err_Display = new Errors();

                string errModel = err_Display.Get_Error_Display_Desc(err_Name);

                //Response.Redirect("Error.aspx");
                ViewData["Message"] = errModel;

            }


Patricksr1972:  here's the apppool settings, see attached.

the app pool was set to defaultapppool, I then changed it to .net 4.0, in the process of re-running it, stand by.
App-Pool.bmp
0
Steve7423Author Commented:
K, found the event viewer.  This is what it says:

3005
                  An unhandled exception has occurred.


IIS APPPOOL\DefaultAppPool
                  HttpException
                  A potentially dangerous Request.Path value was detected from the client (<). at System.Web.HttpRequest.ValidateInputIfRequiredByConfig() at System.Web.HttpApplication.PipelineStepManager.ValidateHelper(HttpContext context)




Changing the app pool setting I still get the error.

IIS APPPOOL\ASP.NET v4.0
                  HttpException
                  A potentially dangerous Request.Path value was detected from the client (<). at System.Web.HttpRequest.ValidateInputIfRequiredByConfig() at System.Web.HttpApplication.PipelineStepManager.ValidateHelper(HttpContext context)
0
Steve7423Author Commented:
I set the validaterequest - false in the config, then took it out and now I'm getting the error on my dev machine.
0
Steve7423Author Commented:
AAAHHHHHHH !!!   you're not going to believe this, this problem was primariy related to a PEBKAC issue (Problem Exists Between Keyboard and Chair).  The message was poping up because there was an if stmt that evaluated a value from a function.  The function returned a string val but the If stmt converted the function val to int32.  the if stmt said if convert.toint32(function) > 0
when it should have been if convert.tostring(function) != "".  

the compiler couldn't resolve this and threw an error.  ASP and IIS is so screwed up with error descriptions that I was chasing a gost.  the error indicated bad characters as I posted above.  when in fact it had nothing to do with that, it was data type conversion.  I'm imbarrased.  

I'm not sure how to manage this question, how would everyone like to deal with this?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
käµfm³d 👽Commented:
If you solved the issue yourself, then you would typically select your own comment as the solution.
0
Steve7423Author Commented:
kaufmed: as per your suggestion, Thank you all for helping me, much appreciated.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.