I have a site I'm playing with to get the hang of Razor Pages. I have a weird situation I'm unsure what is happening or how to resolve. I'm using [TempData] to pass a message on redirect. The app works perfectly locally. Once published to Azure I add a new item and the item is added, I'm redirected to the index page but I never see the TempData message.
Here is my Index page:
public class IndexModel : PageModel
{
private readonly TheFishRoom_MVC_Core.Data.FishRoomDbContext _context;
public IndexModel(TheFishRoom_MVC_Core.Data.FishRoomDbContext context)
{
_context = context;
}
public IList<Coral> Coral { get; set; }
[TempData]
public string Message { get; set; }
public bool ShowMessage => !string.IsNullOrEmpty(Message);
public async Task OnGetAsync(string searchString)
{
if (!String.IsNullOrEmpty(searchString))
{
Coral = await _context.Corals.Where(s => s.Name.Contains(searchString)).ToListAsync();
}
else
{
Coral = await _context.Corals.ToListAsync();
}
}
}
}
Here is my Create page:
namespace TheFishRoom_MVC_Core.Pages.Corals
{
[Authorize(Roles = "Admin")]
public class CreateModel : PageModel
{
private readonly FishRoomDbContext _context;
public CreateModel(FishRoomDbContext context)
{
_context = context;
}
public IActionResult OnGet()
{
return Page();
}
[BindProperty]
public Coral Coral { get; set; }
[TempData]
public string Message { get; set; }
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_context.Corals.Add(Coral);
await _context.SaveChangesAsync();
Message = "New Coral created successfully!";
return RedirectToPage("./Index");
}
}
}
Locally the site works... but not with published to Azure.
Any help is appreciated!