I am beginner for asp.net core. I am building file conversion website. PNG to JPG, PDF to Word etc.. In there I amusing fileuplaod control to upload content for the conversation. Instead using same control on every view I thought put this control in one class and call them. When I search internet I found following two methods
- ViewComponent method
- Partial view method
Now I am confused what to use? Note that on page to page upload file type will be differ. on JPG to PNG converter page I have to restrict the fileuplaod control to only use JPEG images. So I want to pass some parameters to this common control and after Upload process done, I want to call back to the calling page to do specific convertions.
So following things I have implemented so far
I followed Viewcomponentmethod
@model BassModel
@*<form asp-controller="FileUploadViewComponent" enctype="multipart/form-data">*@
<div class="card card-body">
<strong>Select PDF file to convert</strong> <div id="chooseFile"><input type="file" asp-for="@Model" accept="image/*" /></div>
<br />
</div>
<br />
<input asp-action="Index" type="button" value="Upload" class="btn btn-primary" />
<input asp-action="Clear" type="submit" value="Clear" class="btn btn-outline-primary" />
<br />
@*</form>*@
On PDF to word view
<form asp-controller="FileUploadController">
@section _FileUpload{
@await Component.InvokeAsync("_FileUpload", Model)
}
</form>
On _layout page
<div class="container">
<div class="row">
<div class="col-md-7">
<div class="container background_color_white">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<br />
<div class="container background_color_white">
@RenderSection("_FileUpload",false)
</div>
</div>
</div>
So far I done this. Erros are coming. But before I go further, I want to ensure what I do is right. Am I going in the right direction?


