首页 \ 问答 \ Global.asax Session_Start()无限循环(Global.asax Session_Start() endless loop)

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 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
更新时间:2022-09-12 21:09

最满意答案

答案是,你做不到。

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 ...
  • 答案是,你做不到。 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 ...
  • 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,您就可以,如果不是,您将收到错误并且没有任何效果,这就是为什么 ...
  • 这是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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)