Global.asax Session_Start()无限循环(Global.asax Session_Start() endless loop)
在我的Global.asax文件中,我有以下代码处理未处理的异常:
void Application_Error(object sender, EventArgs e) { Application["Exception"] = Server.GetLastError(); Response.Redirect("ErrorPage.aspx"); }
(ErrorPage.aspx从Application检索异常详细信息,并处理它。)
仍然在Global.asax中,我运行以下代码来检查各种与用户相关的东西:
void Session_Start(object sender, EventArgs e) { ... // All sorts of user-related stuff }
通常,错误重定向和用户相关的东西都可以正常工作。
但是,如果在
Session_Start
期间抛出错误,则重定向页面,并再次调用Session_Start !这导致无限循环。
从我在这里和这里找到的,这是因为某种会话cookie问题,这使得浏览器和/或服务器认为会话在每次重定向时重新启动。
有谁知道如何解决cookie问题?
In my Global.asax file, I have the following code that deals with with unhandled exceptions:
void Application_Error(object sender, EventArgs e) { Application["Exception"] = Server.GetLastError(); Response.Redirect("ErrorPage.aspx"); }
(ErrorPage.aspx retrieves the exception details from Application, and deals with it.)
Still in Global.asax, I run the following code to check all sorts of user-related stuff:
void Session_Start(object sender, EventArgs e) { ... // All sorts of user-related stuff }
Normally, both the error redirecting and the user-related-stuff work perfectly fine.
However, if ever an error is thrown during
Session_Start
, the page is redirected, and Session_Start is called all over again!This results in an endless loop.
From what I have found here and here, this happens because of some sort of session-cookies issue, which makes the browser and/or server think that the session is restarted at every redirect.
Does anyone know how to resolve the cookie issue?
原文:https://stackoverflow.com/questions/7723738
最满意答案
答案是,你做不到。
Babel可以将ES7转换为ES6。 但它无法将ES6转换为ES5 ,因为它使用了polyfill(浏览器中加载的.js库)。
因此,因为您无法从源代码中获取ES5,所以您无法使用Uglify。
你将不得不单独依赖gzipping( 这是一个相当大的减少 )。
The answer is, you can't.
Babel can transpile ES7 to ES6. But it can't transpile ES6 to ES5, for that it uses a polyfill (.js library loaded in the browser).
Thus, because you cannot get ES5 from your source code, you cannot use Uglify.
You'll have to rely on gzipping alone (which is a substantial size decrease).
相关问答
更多-
我的结论是正确的 不。扩展名绝对不应该在那里。 固定 resolve: [".ts", ".js"], 应该 : resolve: { extensions: ['.ts', '.js'] }, 如有疑问,请检查测试: https : //github.com/TypeStrong/ts-loader/tree/master/test is my conclusion correct No. Extensions should definitely not be there. Fix resolv ...
-
遗憾的是,没有办法将依赖从ES6转换为ES5。 tsconfig.json该选项仅影响TypeScript代码的转换方式。 你应该做的是使用ES5版本的helper-from-node-modules 。 例如,Angular分发了几个包,用于ES5(umd),ES5,ES6 ......然后,在库的package.json中,有些选项可以告诉打包器(通常是webpack)要使用的版本,具体取决于TypeScript的目标用途。 如果您使用的库不支持该功能,则您唯一的选择是将其自动转换为ES5,也许使用ba ...
-
我知道这并不能直接回答你的问题,但它可能会给你一种解决问题的方法。 我新来反应和webpack自己,但在我的设置中,我使用typescript构建TSX文件,然后将webpack指向转发的js文件。 除了需要运行2步构建过程的复杂性之外,这种方法是否存在任何缺陷我都不知道,但它迄今为止对我而言足够好用了。 使用这种方法,我的webpack配置文件如下所示: module.exports = { devtool: "inline-source-map", entry: './wwwroot/app/c ...
-
您定义了module.rules和module.loaders 。 当webpack看到module.rules它完全忽略了module.loaders ,这只是出于兼容性的原因而存在。 所以你的awesome-typescript-loader没有被使用。 要解决它,只需将所有规则放在modules.rules下: module: { rules: [ { test: /\.tsx?$/, loader: "awesome-typescript-loader" }, { te ...
-
如何让Typescript在Webpack中使用React定位ES5?(How to have Typescript target ES5 with React in Webpack?)[2023-10-21]
答案是,你做不到。 Babel可以将ES7转换为ES6。 但它无法将ES6转换为ES5 ,因为它使用了polyfill(浏览器中加载的.js库)。 因此,因为您无法从源代码中获取ES5,所以您无法使用Uglify。 你将不得不单独依赖gzipping( 这是一个相当大的减少 )。 The answer is, you can't. Babel can transpile ES7 to ES6. But it can't transpile ES6 to ES5, for that it uses a pol ... -
Webpack + Typescript:获取模块解析失败 - 为什么?(Webpack + Typescript : Getting Module Parse failed - why?)[2022-12-23]
TL:DR WebPack不支持使用loaders和rules部分 - 必须使用其中一个或另一个。 经过数小时的调试之后,这是由于在webpack.config.js文件的loaders部分中定义了webpack.config.js加载器。 将它移到rules部分解决了问题。 修改后的webpack.config.js文件如下所示: const path = require('path'); const ExtractTextPlugin = require('extract-text-webpack-pl ... -
TypeScript正在寻找全球的 Promise 。 您在代码中拥有的是在模块(“bluebird”)中声明的Promise ,并在另一个模块中本地使用。 这是一个让解决编译错误并拥有可运行代码的最小方法: test.ts : import * as Bluebird from 'bluebird'; declare global { const Promise: { new
(callback: ( resolve: (thenableOrResu ... -
有一些错误: TS> ES6> JS转换,同时保留原始* .ts文件中的源映射 我用代码显示了一个小的repo,显示错误: https : //github.com/helios1138/--babel-sourcemaps-error-case 克隆,npm安装并运行./build.sh以查看无效的映射错误 尽管在mapRoot中添加了mapRoot属性,但看起来TS2.0 +中的更改会阻止生成相对的sourceMapUrl 参考 TypeScript问题#10612:不使用mapRoot生成相对的sou ...
-
我会尝试尽可能详细地回答您的问题: 您可以使用Browserify在服务器上转换JSX并节省一些时间,React将为其所有组件添加一个标志,以标记在服务器中呈现的组件,但大多数人现在正在做的是使用webpack来转换所有代码之前到运行你的应用程序 您也可以在客户端上执行此操作,但我建议您在运行应用程序之前进行编译。 您可以使用browserify与npm一起将您的代码与babel一起转换为运行您 是的,只要您的探险家和您的客户的探险家支持ES5,您就可以,如果不是,您将收到错误并且没有任何效果,这就是为什么 ...
-
打字稿 - > ES5问题(Typescript -> ES5 issue)[2023-02-07]
这是TypeScript的一个已知且开放的问题 ,应该在TypeScript 2.1中修复。 以下代码: [...(new Array(5))] 翻译成: (new Array(5)).slice(); 但是,ES6的含义并不相同。 见下面的输出: > [...(new Array(5))] [ undefined, undefined, undefined, undefined, undefined ] > (new Array(5)).slice(); [ , , , , ] 预期行为: Arr ...