刷新MVC4应用程序,刷新页面并获取异常 [英] Refresh MVC4 application, refresh the page and get exception

查看:49
本文介绍了刷新MVC4应用程序,刷新页面并获取异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Create a MVC 4 web application and in home page  (Index.cshtml) add
Under this line
Under <h3>We suggest the following</h3>
Add this line
<canvas id="HelloCanvas" style="float: left" > </canvas>

Under this declaration
@{
    ViewBag.Title = "Home Page";
}
Now add this script

<script>
    window.onload = function () {
       var LineContext = $('#HelloCanvas')[0].getContext('2d');
        LineContext.font = "20pt Calibri";
        LineContext.fillStyle = "#024F8C";
        LineContext.textAlign = "left";
        LineContext.textBaseline = "middle";
        LineContext.fillText("Hello world", 0, 10);
        LineContext.save();
    }
</script>

Run this application and you will see "Hello world"  Text.
Now refresh this page from address bar and you will get exception. I spent whole day but no success. Any help will be very much appreciated.

推荐答案

('#HelloCanvas')[0] .getContext('2d');
LineContext.font =20pt Calibri;
LineContext.fillStyle =#024F8C;
LineContext.textAlign =left;
LineContext.textBaseline =middle;
LineContext.fillText(Hello world,0,10);
LineContext.save();
}
< / script >

运行此应用程序,您将看到Hello world文本。
现在从地址栏刷新此页面,您将获得异常。我花了一整天但没有成功。非常感谢任何帮助。
('#HelloCanvas')[0].getContext('2d'); LineContext.font = "20pt Calibri"; LineContext.fillStyle = "#024F8C"; LineContext.textAlign = "left"; LineContext.textBaseline = "middle"; LineContext.fillText("Hello world", 0, 10); LineContext.save(); } </script> Run this application and you will see "Hello world" Text. Now refresh this page from address bar and you will get exception. I spent whole day but no success. Any help will be very much appreciated.


如果问题不明确,我道歉。

这个应用程序工作正常,只有刷新页面才有问题。



很简单我刷新页面时遇到异常

var,LineContext =
I apologized if the question is not clear.
This application works fine and only have problem when we refresh the page.

It is simple I am getting exception when I refresh the page and exception is in JavaScript at
var LineContext =


(''#HelloCanvas'')[0] .getContext('''2d''); <当我们第二次调用getContext时,
。它第一次工作正常。我构建了调试和发布模式。两种情况我都得到例外。

再次这个应用程序工作正常。只有在刷新页面时才会出现异常。

感谢您及时回复。



祝你好运

Agha Khan
(''#HelloCanvas'')[0].getContext(''2d'');
when we try to call getContext 2nd time. It works fine first time. I build in debug and release mode. Both cases I get the exception.
Again this application works fine. Only get exception when we refresh the page.
Thank you for prompt reply.

Best regards
Agha Khan


这篇关于刷新MVC4应用程序,刷新页面并获取异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆