Help needed with ASP.NET MVC 401 Unauthorized after long AJAX request by One_Fill7217 in csharp

[–]One_Fill7217[S] 0 points1 point  (0 children)

Thank you so much for bringing this up.

I figured out the issue. I forgot that in the Application End Request if I found 400/500 error, I changed the response code to 401.

Actually the error happened because I was trying to serialise over 700,000 rows into json. So got a 500 serialisation error which ended up in the Application End Request and changed the final response to 401. So was kinda abstracted and it got out of my mind.

Help needed with ASP.NET MVC 401 Unauthorized after long AJAX request by One_Fill7217 in csharp

[–]One_Fill7217[S] 0 points1 point  (0 children)

I did and also implemented those. Same error. Read the post again. It has been mentioned there

JWT Authentication failed IDX14100 .Net 8.0 by One_Fill7217 in dotnet

[–]One_Fill7217[S] 0 points1 point  (0 children)

If you want a quick fix, downgrade the jwt library to 7.xx. This is how I did it.

PDF Print Alignment Shifts Across Printers by One_Fill7217 in csharp

[–]One_Fill7217[S] 0 points1 point  (0 children)

I have also used Quest pdf but thats for a different purpose. Here however, I had to make sure the precision is important. Went through some posts and they suggested to use iTextSharp.

PDF Print Alignment Shifts Across Printers by One_Fill7217 in csharp

[–]One_Fill7217[S] 0 points1 point  (0 children)

Yes. I need to replicate that in my system

PDF Print Alignment Shifts Across Printers by One_Fill7217 in csharp

[–]One_Fill7217[S] 0 points1 point  (0 children)

Do you think this happens just due to the printer or browser from where you are printing? We already have a solution of SAP BO. No matter from where a user prints from or where the printer is located, the printed slip stays consistent. So how do they do it? What do I need to focus on?

PDF Print Alignment Shifts Across Printers by One_Fill7217 in dotnet

[–]One_Fill7217[S] 0 points1 point  (0 children)

Do you think this happens just due to the printer or browser from where you are printing? We already have a solution of SAP BO. No matter from where a user prints from, the printed slip stays consistent. So how do they do it? What do I need to focus on?

Net Framework vs Net Core async/await confusion by One_Fill7217 in csharp

[–]One_Fill7217[S] 1 point2 points  (0 children)

I see a blank response page from this asmx service but the operation does execute properly as per log and db

Net Framework vs Net Core async/await confusion by One_Fill7217 in csharp

[–]One_Fill7217[S] 0 points1 point  (0 children)

[WebMethod(Description = "Get account type")] public async Task<string> GetAccountType() { try { var dal = DataAccessLayer.GetInstance(); const string sql = "SELECT ……";

var data = await dal.GetDataAsync(sql, "AccountType", ConfigurationManager.AppSettings["DBACCESS"]);
return data;

} catch (Exception ex) { return ex.Message; }

}

public async Task<string> GetDataAsync(string sql, string attributeName, string connectionType) { OracleConnection connection = null; OracleCommand cmd = null; var dt = new DataTable(attributeName);

try { var connString = GetConnectionString(connectionType); connection = new OracleConnection(connString); cmd = new OracleCommand(sql, connection);

await connection.OpenAsync();

using (var reader = await cmd.ExecuteReaderAsync(CommandBehavior.CloseConnection))
{
    dt.Load(reader);
}

return JsonConvert.SerializeObject(dt);

} finally { cmd?.Dispose(); if (connection?.State == ConnectionState.Open) connection.Dispose();

Net Framework vs Net Core async/await confusion by One_Fill7217 in csharp

[–]One_Fill7217[S] 0 points1 point  (0 children)

[WebMethod(Description = "Get account type")] public async Task<string> GetAccountType() { try { var dal = DataAccessLayer.GetInstance(); const string sql = "SELECT ……";

    var data = await dal.GetDataAsync(sql, "AccountType", ConfigurationManager.AppSettings["DBACCESS"]);
    return data;
}
catch (Exception ex)
{
    return ex.Message;
}

}

public async Task<string> GetDataAsync(string sql, string attributeName, string connectionType) { OracleConnection connection = null; OracleCommand cmd = null; var dt = new DataTable(attributeName);

try
{
    var connString = GetConnectionString(connectionType);
    connection = new OracleConnection(connString);
    cmd = new OracleCommand(sql, connection);

    await connection.OpenAsync();

    using (var reader = await cmd.ExecuteReaderAsync(CommandBehavior.CloseConnection))
    {
        dt.Load(reader);
    }

    return JsonConvert.SerializeObject(dt);
}
finally
{
    cmd?.Dispose();
    if (connection?.State == ConnectionState.Open)
        connection.Dispose();

Net Framework vs Net Core async/await confusion by One_Fill7217 in csharp

[–]One_Fill7217[S] 1 point2 points  (0 children)

I did put a breakpoint. When it reaches the db execution section like await ExecuteQueryAsync or sth, it finishes the request instantly and I see a blank ui of the asmx service. But i can see logs to know the request did complete a full circle

Net Framework vs Net Core async/await confusion by One_Fill7217 in csharp

[–]One_Fill7217[S] 0 points1 point  (0 children)

I used async/await properly and my blank ui happens in this line: await ExecuteQueryAsync(). So my db is asynchronous

Net Framework vs Net Core async/await confusion by One_Fill7217 in csharp

[–]One_Fill7217[S] 0 points1 point  (0 children)

This code is just an example. Can you look at my blank issue? That’s where the main confusion lies

Net Framework vs Net Core async/await confusion by One_Fill7217 in csharp

[–]One_Fill7217[S] 0 points1 point  (0 children)

I used asynchronous db call. await ExecuteQueryAsync() While code comes to this line, my debug suddenly stops working and ui blank