cancel
Showing results for 
Search instead for 
Did you mean: 

Serialized Session in .NET MVC

Former Member
0 Kudos

I have gotten to the point where I can retrieve a serialized session from SDK DLL's used natively in my .NET application.  We then found a technique for submitting the serialized session to the BI/BOE server as an input in an HTML form with a POST method, and we are able to retrieve a report and target it at an HTML iFrame.  Those were good steps forward for us.

Now I am trying to implement this HTML form submit in an .NET MVC view.  I am trying to pass the Serialized Session back to the application server (after it's been HTML encoded) through an AJAX call and JSON (this is in JavaScript).   JSON/AJAX apparently doesn't like that the Serialized Session has lots of special characters in it.  I've tried a couple of things to escape all the special characters, but no luck.  The AJAX call just keeps giving me an undefined error.  Has anyone else run into this type of problem?  My code right now looks like this:

       String.prototype.escapeSpecialChars = function () {

            return this

               .replace(/[\\]/g, '\\\\')

        .replace(/[\/]/g, '\\/')

        .replace(/[\b]/g, '\\b')

        .replace(/[\f]/g, '\\f')

        .replace(/[\n]/g, '\\n')

        .replace(/[\r]/g, '\\r')

        .replace(/[\t]/g, '\\t')

        .replace(/[\"]/g, '\\"')

        .replace(/\\'/g, "\\'");

        }

        var s = localStorage["SerSession"];

        var myJSONString = JSON.stringify({ SerSession: s, ReportID: "238771" });

        var myEscapedJSONString = myJSONString.escapeSpecialChars();


        $.ajax({

            type: 'GET',

            url: '@Url.Action("GetReport")',

            data: myEscapedJSONString,

            async: false,

            contentType: 'application/json',

            dataType: 'json',

            success: function (result) {

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Solved this problem of passing the session through AJAX to an MVC controller action by making the AJAX call a "POST" instead of a "GET".

Answers (0)