paulman176
paulman176
CC#
Created by paulman176 on 7/1/2023 in #help
❔ Can't succesfully run visual studio project
so it must be something else
23 replies
CC#
Created by paulman176 on 7/1/2023 in #help
❔ Can't succesfully run visual studio project
it still fails when i do that
23 replies
CC#
Created by paulman176 on 7/1/2023 in #help
❔ Can't succesfully run visual studio project
too bad ://
23 replies
CC#
Created by paulman176 on 7/1/2023 in #help
❔ Can't succesfully run visual studio project
so i guess there is nothing running
23 replies
CC#
Created by paulman176 on 7/1/2023 in #help
❔ Can't succesfully run visual studio project
i get nothing in return in the terminal
23 replies
CC#
Created by paulman176 on 7/1/2023 in #help
❔ Can't succesfully run visual studio project
whenever i do that paulvanmierlo@Pauls-MacBook-Pro-2 ~ % lsof -i:62870
23 replies
CC#
Created by paulman176 on 7/1/2023 in #help
❔ Can't succesfully run visual studio project
but my firewall is off entirely
23 replies
CC#
Created by paulman176 on 7/1/2023 in #help
❔ Can't succesfully run visual studio project
i am on a new mac atm
23 replies
CC#
Created by paulman176 on 7/1/2023 in #help
❔ Can't succesfully run visual studio project
this is my launch file
23 replies
CC#
Created by paulman176 on 7/1/2023 in #help
❔ Can't succesfully run visual studio project
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:62869/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/test",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"EJ2APIServices": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/test",
"applicationUrl": "http://localhost:62870/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:62869/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/test",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"EJ2APIServices": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/test",
"applicationUrl": "http://localhost:62870/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
23 replies
CC#
Created by paulman176 on 7/1/2023 in #help
❔ Can't succesfully run visual studio project
i got that launch file
23 replies
CC#
Created by paulman176 on 7/1/2023 in #help
❔ Can't succesfully run visual studio project
this is the github repository i cloned!
23 replies
CC#
Created by paulman176 on 7/1/2023 in #help
❔ Can't succesfully run visual studio project
23 replies
CC#
Created by paulman176 on 5/19/2023 in #help
❔ Unable to process post request with asp.net core
and this is how i am fetching the data
DocumentEditorComponent.Inject(Toolbar);
export default function Documenteditor() {
// Function to handle the document import
const importDocument = (file) => {
const formData = new FormData();
formData.append('file', file); // Assuming you have a file object from an input field

fetch('https://localhost:7166/Import/Import', {
method: 'POST',
body: formData,
})
.then((response) => {
if (response.ok) {
return response.json();
} else {
throw new Error('Error importing document');
}
})
.then((document) => {
console.log(document); // Handle the imported document data
})
.catch((error) => {
console.error('Error importing document:', error);
});
};

// Event handler for file input change
const fileInputOnChange = (event) => {
const file = event.target.files[0];
importDocument(file);
};

return (
<>
<input type="file" onChange={fileInputOnChange} />
<DocumentEditorContainerComponent id="container" height={'1000px'} enableToolbar={true}>
<Inject services={[Toolbar]} />
</DocumentEditorContainerComponent>
</>
);
}
DocumentEditorComponent.Inject(Toolbar);
export default function Documenteditor() {
// Function to handle the document import
const importDocument = (file) => {
const formData = new FormData();
formData.append('file', file); // Assuming you have a file object from an input field

fetch('https://localhost:7166/Import/Import', {
method: 'POST',
body: formData,
})
.then((response) => {
if (response.ok) {
return response.json();
} else {
throw new Error('Error importing document');
}
})
.then((document) => {
console.log(document); // Handle the imported document data
})
.catch((error) => {
console.error('Error importing document:', error);
});
};

// Event handler for file input change
const fileInputOnChange = (event) => {
const file = event.target.files[0];
importDocument(file);
};

return (
<>
<input type="file" onChange={fileInputOnChange} />
<DocumentEditorContainerComponent id="container" height={'1000px'} enableToolbar={true}>
<Inject services={[Toolbar]} />
</DocumentEditorContainerComponent>
</>
);
}
26 replies
CC#
Created by paulman176 on 5/19/2023 in #help
❔ Unable to process post request with asp.net core
this is the controller code:
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Syncfusion.EJ2.DocumentEditor;
using System.IO;

[ApiController]
[Route("[controller]")]
public class ImportController : ControllerBase
{

[AcceptVerbs("Post")]
[HttpPost]
[EnableCors("AllowAllOrigins")]
[Route("Import")]
public string Import(IFormCollection data)
{
if (data.Files.Count == 0)
return null;
Stream stream = new MemoryStream();
IFormFile file = data.Files[0];
int index = file.FileName.LastIndexOf('.');
string type = index > -1 && index < file.FileName.Length - 1 ?
file.FileName.Substring(index) : ".docx";
file.CopyTo(stream);
stream.Position = 0;

WordDocument document = WordDocument.Load(stream, GetFormatType(type.ToLower()));
string json = Newtonsoft.Json.JsonConvert.SerializeObject(document);
document.Dispose();
return json;
}

private FormatType GetFormatType(string fileExtension)
{
if (string.IsNullOrEmpty(fileExtension))
throw new NotSupportedException("EJ2 DocumentEditor does not support this file format.");
switch (fileExtension)
{
case ".docx":
return FormatType.Docx;
case ".doc":
return FormatType.Doc;
case ".rtf":
return FormatType.Rtf;
case ".txt":
return FormatType.Txt;
// Add more cases for other supported file extensions if needed
default:
return FormatType.Docx; // Default to a specific format if the extension is not recognized
}
}
}
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Syncfusion.EJ2.DocumentEditor;
using System.IO;

[ApiController]
[Route("[controller]")]
public class ImportController : ControllerBase
{

[AcceptVerbs("Post")]
[HttpPost]
[EnableCors("AllowAllOrigins")]
[Route("Import")]
public string Import(IFormCollection data)
{
if (data.Files.Count == 0)
return null;
Stream stream = new MemoryStream();
IFormFile file = data.Files[0];
int index = file.FileName.LastIndexOf('.');
string type = index > -1 && index < file.FileName.Length - 1 ?
file.FileName.Substring(index) : ".docx";
file.CopyTo(stream);
stream.Position = 0;

WordDocument document = WordDocument.Load(stream, GetFormatType(type.ToLower()));
string json = Newtonsoft.Json.JsonConvert.SerializeObject(document);
document.Dispose();
return json;
}

private FormatType GetFormatType(string fileExtension)
{
if (string.IsNullOrEmpty(fileExtension))
throw new NotSupportedException("EJ2 DocumentEditor does not support this file format.");
switch (fileExtension)
{
case ".docx":
return FormatType.Docx;
case ".doc":
return FormatType.Doc;
case ".rtf":
return FormatType.Rtf;
case ".txt":
return FormatType.Txt;
// Add more cases for other supported file extensions if needed
default:
return FormatType.Docx; // Default to a specific format if the extension is not recognized
}
}
}
26 replies
CC#
Created by paulman176 on 5/19/2023 in #help
❔ Unable to process post request with asp.net core
i am using the same port as URL for the get request as for the post request i am still not able to perform
26 replies
CC#
Created by paulman176 on 5/19/2023 in #help
❔ Unable to process post request with asp.net core
for the sample get request
26 replies
CC#
Created by paulman176 on 5/19/2023 in #help
❔ Unable to process post request with asp.net core
also this is my console log from within the browser:
OK response received
OK response received
26 replies
CC#
Created by paulman176 on 5/19/2023 in #help
❔ Unable to process post request with asp.net core
so maybe there is something wrong with how i am fetching the data?
26 replies
CC#
Created by paulman176 on 5/19/2023 in #help
❔ Unable to process post request with asp.net core
and both responded with OK
26 replies